1. 程式人生 > 其它 >go get -u github.com/....失敗問題解決

go get -u github.com/....失敗問題解決

F:\spider\src\icnet\src\main>go get -u github.com/gocolly/colly
package github.com/gocolly/colly: directory "F:\\spider\\src\\github.com\\gocolly\\colly" is not using a known version control system

F:\spider\src\icnet\src\main>go get -u github.com/gocolly/colly
# cd .; git clone -- https://github.com/PuerkitoBio/goquery F:\spider\src\github.com\PuerkitoBio\goquery
Cloning into 'F:
\spider\src\github.com\PuerkitoBio\goquery'... fatal: unable to access 'https://github.com/PuerkitoBio/goquery/': OpenSSL SSL_read: Connection was reset, errno 10054 package github.com/PuerkitoBio/goquery: exit status 128 # cd .; git clone -- https://github.com/antchfx/xpath F:\spider\src\github.com\antchfx\xpath Cloning into 'F:
\spider\src\github.com\antchfx\xpath'... fatal: unable to access 'https://github.com/antchfx/xpath/': Failed to connect to github.com port 443 after 21056 ms: Timed out package github.com/antchfx/xpath: exit status 128 # cd .; git clone -- https://github.com/golang/groupcache F:\spider\src\github.com\golang\groupcache Cloning into 'F:
\spider\src\github.com\golang\groupcache'... fatal: unable to access 'https://github.com/golang/groupcache/': Failed to connect to github.com port 443 after 21057 ms: Timed out package github.com/golang/groupcache/lru: exit status 128 # cd .; git clone -- https://go.googlesource.com/net F:\spider\src\golang.org\x\net Cloning into 'F:\spider\src\golang.org\x\net'... fatal: unable to access 'https://go.googlesource.com/net/': Failed to connect to go.googlesource.com port 443 after 21118 ms: Timed out package golang.org/x/net/html: exit status 128 cannot find package "golang.org/x/net/html/charset" in any of: E:\Program Files\Go\src\golang.org\x\net\html\charset (from $GOROOT) F:\spider\src\golang.org\x\net\html\charset (from $GOPATH) # cd .; git clone -- https://github.com/antchfx/xmlquery F:\spider\src\github.com\antchfx\xmlquery Cloning into 'F:\spider\src\github.com\antchfx\xmlquery'... fatal: unable to access 'https://github.com/antchfx/xmlquery/': OpenSSL SSL_read: Connection was reset, errno 10054 package github.com/antchfx/xmlquery: exit status 128 # cd .; git clone -- https://github.com/gobwas/glob F:\spider\src\github.com\gobwas\glob Cloning into 'F:\spider\src\github.com\gobwas\glob'... fatal: unable to access 'https://github.com/gobwas/glob/': Failed to connect to github.com port 443 after 21056 ms: Timed out package github.com/gobwas/glob: exit status 128 # cd .; git clone -- https://github.com/kennygrant/sanitize F:\spider\src\github.com\kennygrant\sanitize Cloning into 'F:\spider\src\github.com\kennygrant\sanitize'... fatal: unable to access 'https://github.com/kennygrant/sanitize/': Failed to connect to github.com port 443 after 21059 ms: Timed out package github.com/kennygrant/sanitize: exit status 128 # cd .; git clone -- https://github.com/temoto/robotstxt F:\spider\src\github.com\temoto\robotstxt Cloning into 'F:\spider\src\github.com\temoto\robotstxt'... fatal: unable to access 'https://github.com/temoto/robotstxt/': OpenSSL SSL_read: Connection was reset, errno 10054 package github.com/temoto/robotstxt: exit status 128 package google.golang.org/appengine/urlfetch: unrecognized import path "google.golang.org/appengine/urlfetch": https fetch: Get "https://google.golang.org/appengine/urlfetch?go-get=1": dial tcp 142.25 1.43.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 r espond.

上面執行go get -u github.com/gocolly/colly命令失敗

下面方法成功解決:

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct

再執行

F:\spider\src\icnet\src\main>go get -u github.com/gocolly/colly
go: downloading github.com/gocolly/colly v1.2.0
go: downloading github.com/temoto/robotstxt v1.1.2
go: downloading golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9
go: downloading google.golang.org/appengine v1.6.7
go: downloading github.com/antchfx/htmlquery v1.2.4
go: downloading github.com/antchfx/xmlquery v1.3.8
go: downloading github.com/PuerkitoBio/goquery v1.8.0
go: downloading github.com/antchfx/xpath v1.2.0
go: downloading github.com/andybalholm/cascadia v1.3.1
go: downloading github.com/golang/protobuf v1.3.1
go: downloading golang.org/x/text v0.3.6
go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: downloading github.com/golang/protobuf v1.5.2
go: downloading golang.org/x/text v0.3.7
go: downloading google.golang.org/protobuf v1.26.0
go: downloading google.golang.org/protobuf v1.27.1

完美解決