This is a creation in Article, where the information may have evolved or changed.
The boundary of the defer
Defer is a function-bound, that is, it will only run when the current function is going to exit.
Return of Nested Channel Select
- For nested the same channel Select, the best way to get layers back is to close the channel directly
package mainimport ( "fmt" "time")func main() { stopc := make(chan int) go func() { select { case <-stopc: fmt.Println("stopc 0") select { case <-stopc: fmt.Println("stopc 1") } fmt.Println("stopc 2") } }() // stopc <- 2 // stopc <- 2 close(stopc) time.Sleep(time.Second * 5)}
[Also See:go sandbox*
Fork the correct posture of the other project
For example, there is a project "Http://github.com/sirupsen/logrus ...", you see he is a little upset want to pity dorado things. So fork a new project "Http://github.com/auxten/logrus ...", but there will be a lot of "import" http://github.com/sirupsen/logrus/xxx in the code ... ""
You go directly to modify the code project will still refer to the original, pull request the original author can not be passed quickly, urgent, how to do?
Go get someone else code, here is
go get github.com/sirupsen/logrus
Add a new remote to the project directly, pointing to your own repo, command:
git remote add auxten git@github.com:auxten/logrus.git
Create a new branch, called the Aux Bar, and let the branch point to this remote. Command:
git checkout -b aux && git branch -u auxten/master aux
The final. Git/config is likely to look like this:
[core]repositoryformatversion = 0 filemode = truebare = falselogallrefupdates = trueignorecase = trueprecomposeunicode = true[remote "origin"]url = https://github.com/sirupsen/logrusfetch = +refs/heads/*:refs/remotes/origin/*[remote "auxten"]url = git@github.com:auxten/logrus.gitfetch = +refs/heads/*:refs/remotes/auxten/*[branch "aux"]remote = auxtenmerge = refs/heads/master[push]default = upstream
The push code is used
git push -u auxten aux:master
This command means: Push and set the upstream of Aux to Auxten master.
The
method is not perfect, but it can at least gracefully solve the problem of local development and compilation.