Solution gopm get under way go.mod successful installation, after being given the import or

Update

Before you download the update at the source will not be so many things

go env -w GOPROXY=https://goproxy.cn,direct

————————————————————————————————————————————

version

go 1.13

process

Start directly go go get gopkg.in/gomail.v2when prompted:

go get gopkg.in/gomail.v2: module gopkg.in/gomail.v2: Get 
https://proxy.golang.org/gopkg.in/gomail.v2/@v/list: dial tcp 216.58.200.49:443: 
connectex: A connection attempt failed because the connected party did not 
properly respond after a period of time, or established connection failed because
 connected host has failed to respond.

Directly behind gopm get -g gopkg.in/gomail.v2, the installation was successful, automatic installation to /$GOPATH/src/gopkg.inthe next, because the project with a go.modway to put the package copied to the $GOPATH/pkg/mod/gopkg.innext, and then the project was a direct import "gopkg.in/gomail.v2"
result also found a bag, but still failed to download

go: finding gopkg.in/gomail.v2 latest
go: downloading gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
verifying gopkg.in/gomail.v2@v2.0.0-20160411212932-81ebce5c23df: 
gopkg.in/gomail.v2@v2.0.0-20160411212932-81ebce5c23df: Get 
https://sum.golang.org/lookup/gopkg.in/gomail.v2@v2.0.0-20160411212932-
81ebce5c23df: dial tcp 172.217.24.17:443: connectex: A connection attempt 
failed because the connected party did not properly respond after a period of 
time, or established connection failed because connected host has failed to 
respond.

solution

Later learned that the default will go after 1.13 with sum check, that is go.sum, as though you just downloaded package download success, but the directory name gomail.v2, so modulestill think in here you can not find the package, then automatically downloaded to the back of the it removed, because China can not access gopkg.in, so the download failed. .

Now only need to GOPROXYset up just fine

go env -w GOPROXY=https://goproxy.cn 

Then run the project

go run ./main.go
go: finding gopkg.in/gomail.v2 latest                      
go: downloading gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
go: extracting gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df

Success, then you can see go.sumadded the following information

gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=

to sum up

Sometimes gopm getafter downloaded, the occurrence of the above, you can follow the prompts error will modify the directory name click on it, such as tips verifying gopkg.in/[email protected]:, just directly to the gopmpackage name change what is installed [email protected]:on it

Published 48 original articles · won praise 56 · views 20000 +

Guess you like

Origin blog.csdn.net/zhetmdoubeizhanyong/article/details/101164167