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, how to want to return layers, the best way is to directly close the channel
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 <-2close (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 uncomfortable want to pity dorado things. So fork a new project "Http://github.com/auxten/logrus", but the code will have a lot of "import" Http://github.com/sirupsen/logrus/xxx ""
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 your project directly, pointing to your own repo, command:
git remote add auxten [email protected]: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 probably looks like this:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true[remote "origin"] url = https://github.com/sirupsen/logrus fetch = + refs/heads/*:refs/remotes/origin/*[remote "Auxten"] url = [email protected]:auxten/logrus.git fetch = +refs/heads/*: refs/remotes/auxten/*[branch "aux"] remote = auxten merge = refs/heads/master[push] default = upstream
⑤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 at least it is more elegant to solve the problem of local development compilation.
This article is from the "Reboot DevOps Development" blog, please be sure to keep this source http://opsdev.blog.51cto.com/2180875/1884242