In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about what to do when go get encounters a wall. Many people may not know much about it. In order to let everyone know more, Xiaobian summarizes the following contents for everyone. I hope everyone can gain something according to this article.
As a novice to go from py, we need to be familiar with the build and installation of the package or module when using a third-party package, such as installing modules with tools such as pip or easy_install, which often encounters dependencies on the underlying library or toolkit or network timeout that causes module installation to fail. However, in the process of using go, although it is not necessary to solve various dependencies for a complex module like py, it is not necessarily smooth sailing in the process of using go get. For example, when you download the package on golang.org, sorry, generally it will be dropped by the wall.
Why did it fall off the wall?
&^*(^*%^&*)&*^&*%$$^&*(*()&*^&%^&()**(%$%&*(^%^*(*)*) Anyway, for some reason, it and its owner Google have been blocked.
How?
Two ways: The first is nothing more than using VPN technology, and then in the local distribution of a proxy or something, but since they are open source things, they must be able to clone down from github. So the second way is to clone directly from github, and then make it a package that can be recognized by go. github.com is definitely not blocked now. VPN way is to build a ladder and then configure the proxy can be directly used to get, here mainly talk about the second way to install third-party packages.
Suppose I want to use the docker client of go language to package and modify something. Go get -v can view the details of the installation package.
$go get -v github.com/fsouza/go-dockerclientpackage golang.org/x/net/html: unrecognized import path "golang.org/x/net/html" (https fetch: Get https://golang.org/x/net/html? go-get=1: dial tcp 216.239.37.1:443: i/o timeout)package golang.org/x/net/html/atom: unrecognized import path "golang.org/x/net/html/atom" (https fetch: Get https://golang.org/x/net/html/atom? go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
From the above tips, you can probably guess that the local server must not be able to access golang.org, so when downloading golang.org related packages, it cannot download and cause dockerclient to download failure.
Because go get actually downloads the package and installs it locally, we can also clone the golang.org package locally and install it again.
1. View Configuration Environment
The main ones are GOPATH and GOROOT.
# go envGOARCH="amd64"GOBIN=""GOEXE=""GOHOSTARCH="amd64"GOHOSTOS="linux"GOOS="linux"GOPATH="/export/test-go"GORACE=""GOROOT="/export/go"GOTOOLDIR="/export/go/pkg/tool/linux_amd64"GO15VENDOREXPERIMENT="1"CC="gcc"GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"CXX="g++"CGO_ENABLED="1"
Note: All downloaded packages will be placed in GOPATH by default, so this directory is necessary, and generally contains src pkg bin three directories, respectively, to store source packages, compiled packages and executable files.
2. Download and install golang.org/x/net
To keep the package imported the same way, we need to construct a directory structure under the src directory
$mkdir -p $GOPATH/src/golang.org/x/$cd $GOPATH/src/golang.org/x/$git clone https://github.com/golang/net.git net $go install net
If there is no prompt after executing go install, it means that the installation is complete.
3. Install go dockerclient# go get -v github.com/fsouza/go-dockerclient github.com/fsouza/go-dockerclient (download)github.com/docker/docker (download) github.com/docker/go-units (download) github.com/hashicorp/go-cleanhttp (download) networkgithub.com/docker/docker/pkg/promisegithub.com/docker/docker/api/types/blkiodevgithub.com/docker/docker/api/types/mountgithub.com/docker/docker/api/types/strslicegithub.com/docker/docker/vendor/github.com/docker/go-connections/natgithub.com/docker/docker/vendor/github.com/docker/go-unitsgithub.com/docker/docker/api/types/versionsgithub.com/docker/docker/api/types/registrygithub.com/docker/docker/vendor/github.com/Sirupsen/logrusgithub.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/usergithub.com/docker/docker/vendor/golang.org/x/net/contextgithub.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/systemgithub.com/docker/docker/vendor/github.com/Nvveen/Gottygithub.com/docker/docker/pkg/jsonloggithub.com/docker/docker/pkg/termgithub.com/docker/docker/pkg/stdcopygithub.com/docker/go-unitsgithub.com/hashicorp/go-cleanhttpgolang.org/x/net/contextgithub.com/docker/docker/api/types/filtersgithub.com/docker/docker/pkg/systemgithub.com/docker/docker/pkg/ioutilsgolang.org/x/net/context/ctxhttpgithub.com/docker/docker/api/types/containergithub.com/docker/docker/pkg/idtoolsgithub.com/docker/docker/api/types/swarmgithub.com/docker/docker/pkg/fileutilsgithub.com/docker/docker/pkg/poolsgithub.com/docker/docker/api/typesgithub.com/docker/docker/pkg/homedirgithub.com/docker/docker/pkg/jsonmessagegithub.com/docker/docker/pkg/archivegithub.com/docker/docker/optsgithub.com/fsouza/go-dockerclient
Use the-v parameter to view all packages associated with the package and see that it has been successfully installed
4. Testing Docker client usage github.com/fsouza/go-dockerclient
Example: View downloaded images on the current docker host
#cat JFdocker.gopackage mainimport ( "fmt" "github.com/fsouza/go-dockerclient" "strings")func main() { //define a socker file path endpoint := "unix://var/run/docker.sock" //create a docker client link client, err := docker.NewClient(endpoint) //Determine if there is an exception and catch it if err != nil { panic(err) } //use created client for listimages operation images, err := client.ListImages(docker.ListImagesOptions{All: false}) if err != nil { panic(err) } //Iterate all images information using range for _, img := range images { fmt.Printf("ID:%v\tTag:%v\t\t Size:%v\t\t VSize:%v\n", //image.ID is a string and starts with sha215: strings.Split ('strings ',' split') can split the result and store it in slices strings.Split(img.ID, ":")[1][:12], img.RepoTags, img.Size, img.VirtualSize) #go build JFDocker.gosh-4.2# ./ JFDocker ID:e740f4a4a24d Tag:[centos6.8-test-app:v2] Size:2411566940 VSize:2411566940ID:d5cb0af109de Tag:[centos6.8-test-app:latest] Size:2408322269 VSize:2408322269ID:67591570dd29 Tag:[centos:latest] Size:191839169 VSize:191839169
As you can see, you can now successfully develop programs using go's docker client. At this point, we have successfully resolved the problem that go get cannot install golang.org related packages.
After reading the above, do you have any further understanding of what to do when go get encounters a wall? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.
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.