In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to compile go and achieve go get progress display, the article is very detailed, has a certain reference value, interested friends must read it!
First, attach the compiled Go package that displays the progress of go get:
Centos7 direct decompressed version of go: http://pan.baidu.com/s/1mik3cI8
Windows7 direct decompressed version of go: http://pan.baidu.com/s/1jIaxKEE
1. Modify the go get progress display before compilation:
Because beego's package on github.com is a little large, go get github.com/leanote/leanote/app will be slow, this will run for a few minutes or more, and friends who don't know will think it's stuck. After looking for go get that doesn't have an option to output progress, I decided to modify the golang source code (don't think it's very technical, it's not go code?).
Look at the source code of golang src/cmd/go is the source code of go command, where get.go is the code of go get command, build.go is the code of go build.
At the beginning, I took a detour and wanted to change the get.go to show the progress. After thinking about it, go get actually downloaded it from the warehouse by calling the commands of git, hg and svn. From this idea, I found vcs.go (the full name of vcs is version control system). Sure enough, it included commands for calling git, hg, and svn. The problem is easily solved:
Modify the git clone command and add the-- progress option to output the progress
Modify where cmd.Run () executes so that it locates the output to the standard output stream
1. Modify the git clone command, find the following code, and change it to clone-- progress {repo} {dir} in createdCmd
Other commands hg, svn... The method of adding progress is similar
/ / vcsGit describes how to use Git.var vcsGit = & vcsCmd {name: "Git", cmd: "git", createCmd: "clone {repo} {dir}", / / modify here to clone-- progress {repo} {dir} downloadCmd: "pull-- ff-only"}
two。 Redirect output stream
Find the run1 () method and add two lines under cmd.Stderr = & buf, such as:
Var buf bytes.Buffer cmd.Stdout = & buf cmd.Stderr = & buf cmd.Stdout = os.Stdout / / Redirect standard output cmd.Stderr = os.Stderr / / redirect standard output err = cmd.Run ()
Ok, done. Next, execute all.bash under golang source code src to recompile golang. It will take some time to compile. After compilation, try using go get:
You don't have to worry when you see the progress bar.
Previously, modify the golang source code to close the error of unused variables and unused packages:
Turn off variable declared but not used and package imported but not used for golang
Second, compile Go under window7:
Make a copy of the go source:
Set GOROOT_BOOTSTRAP=C:\ Go1.7
After setting the environment variable, you need to restart to take effect!
Download and install: MinGW-Minimalist GNU for Windows
Https://sourceforge.net/projects/mingw/
You can also download TDM-GCC MinGW Compiler directly.
Add to path:
Set PATH=.;C:\ TDM-GCC-64\ bin\
Third, compile Go under Centos7:
In the same way as linux, execute the compilation script to sh all.bash under src
When the compilation is complete, execute go get:
The above is all the contents of the article "how to compile go and achieve go get progress display". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.