这里面收集了 Go 的各个方面的资料。
https://github.com/astaxie/build-web-application-with-golang
https://books.studygolang.com/gopl-zh/index.html
http://gopl-zh.b0.upaiyun.com/
http://docs.ruanjiadeng.com/gopl-zh/
http://2goo.info/media/html/gopl-zh-gh-pages/
http://docs.plhwin.com/gopl-zh/
http://gopl-zh.simple-is-best.tk/
https://docs.hacknode.org/gopl-zh/
https://gobyexample.com 这里有很多 Go 基础的例子。
go get golang.org/x/tour/gotour
如果用 go get 下载不下来的时候,就到下面的网址去下载。
https://www.golangtc.com/download/package
https://github.com/enocom/gopher-reading-list
https://github.com/golang/go/wiki/CodeReviewComments
这是每年的 GopherChina,不同的公司分享的资料,很值得阅读。
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
当要输入 git commit 时,只需要输入 git ci。
$ git config --global alias.unstage 'reset HEAD --'
这会使下面的两个命令等价:
$ git unstage fileA
$ git reset HEAD -- fileA
$ git config --global alias.last 'log -1 HEAD'
这样,可以轻松地看到最后一次提交:
$ git last
commit 66938dae3329c7aebe598c2246a8e6af90d04646
Author: Josh Goebel <dreamer3@example.com>
Date: Tue Aug 26 19:48:51 2008 +0800
test for current head
Signed-off-by: Scott Chacon <schacon@example.com>
$ git config --global alias.jlog 'log --oneline --decorate --graph --all'
$ git jlog
https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001375234012342f90be1fc4d81446c967bbdc19e7c03d3000
«ProGit»
同步存储库的某个 fork 以使其保持与上游存储库的最新状态。
在将你的 fork 与上游存储库同步之前,必须先配置一个指向 Git 中上游存储库的远程存储库。
master
的 commits 将会被存储在本地分支中,upstream/master
。$ git fetch upstream
remote: Counting objects: 75, done.
remote: Compressing objects: 100% (53/53), done.
remote: Total 62 (delta 27), reused 44 (delta 9)
Unpacking objects: 100% (62/62), done.
From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY
* [new branch] master -> upstream/master
master
主分支。$ git checkout master
Switched to branch 'master'
upstream/master
的更改合并到你的本地 master
主分支中。这会使你的 fork 的 master
主分支与上游存储库保持同步,而不会丢失本地的修改。$ git merge upstream/master
Updating a422352..5fdff0f
Fast-forward
README | 9 -------
README.md | 7 ++++++
2 files changed, 7 insertions(+), 9 deletions(-)
delete mode 100644 README
create mode 100644 README.md
如果你的本地分支没有任何的 commits 提交,Git 将会执行 “fast-forward” 合并:
$ git merge upstream/master
Updating 34e91da..16c56ad
Fast-forward
README.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
提示:同步你的 fork 只会更新你的本地版本库。要在 GitHub 上更新你的 fork,你必须推送你的更改。
via: https://help.github.com/articles/syncing-a-fork/
你必须配置指向 Git 中上游的远程存储库,以便把你在 fork 中进行的更改同步到原始存储库。这也允许你把原始存储库中所做的更改同步到 fork。
$ git remote -v
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
$ git remote -v
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
via: https://help.github.com/articles/configuring-a-remote-for-a-fork/
https://leetcode.com/problems/jewels-and-stones/description/
You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.
The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so “a” is considered a different type of stone from “A”.
Example 1:
Input: J = "aA", S = "aAAbbbb"
Output: 3
Example 2:
Input: J = "z", S = "ZZ"
Output: 0
Note:
func numJewelsInStones(J string, S string) int {
num := 0
m := make(map[rune]int)
for _, v := range J {
m[v] = 1
}
for _, v := range S {
if _, ok := m[v]; ok {
num++
}
}
return num
}