Go Language Learning Tips (i)

Source: Internet
Author: User
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, how to want to return layers, the best way is to directly close the channel

Package Listen Mainimport ("FMT" "Time") Func listen to main () Listen {Stopc Listen: = Listen to make (chan listen int) go listen to Func () Listen {Select Listen {case listen to <-stopc:fmt. Println ("Stopc Listen 0") Select Listen {case listen to <-stopc:fmt. Println ("Stopc listen 1")}fmt. Println ("Stopc Listen 2")}} ()//listen to STOPC <-listen to 2//listen to Stopc listen to <-listen to 2close (STOPC) time. Sleep (time. Second listen to 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 listen

Go Listen get Listen Github.com/sirupsen/logrus

② add a new remote to your project directly, pointing to your own repo, command:

Git listen to remote listen add listen to Auxten listen to Git@github.com:auxten/logrus.git

③ Create a new branch, called the Aux Bar, and let the branch point to this remote. Command:

GIT Listen checkout listen-B listen to aux listen && listen git listen to branch listen to-u listen to auxten/master listen to aux

④ the final. Git/config probably looks like this:

[Core] Listen to hear repositoryformatversion listen = Listen to listen to listen to listen to hear the 0 listen to listen listen to listen to hear FileMode hear Listen true listen to listen to listen ignorecase listen to listen to listen to true listen to hear precomposeunicode listen to listen to True[remote listen to "origin" listen to hear the URL listen = Listen to https://github.com/sirupsen/ Logrus Listen, listen, listen, listen and listen to +refs/heads/*:refs/remotes/origin/*[remote listen to the "Auxten" listen to the URL listen to listen to hear = listen to git@github.com:auxten/ Logrus.git Listen, listen, listen, hear, hear, listen to the +refs/heads/*:refs/remotes/auxten/*[branch listen to "aux" Listen to listen to listen to the remote listen to listen to hear the Auxten listen to listen to hear listen to hear the merge listen Listen Refs/heads/master[push] Listen to the default listen = Listen to upstream

⑤push code is used

Git listen push Listen-U listen to Auxten listen to 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 originates from: Https://zhuanlan.zhihu.com/p/24436747?refer=auxten


listen python actual Combat class introduction --- November 26 (Saturday) class opened

http://www.51reboot.com/course/actual/

QQ Registration: 979950755 Listen

This article is from the "Reboot DevOps Development" blog, please be sure to keep this source http://opsdev.blog.51cto.com/2180875/1884242

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.