搜索
简帛阁>技术文章>go get golang.org/x 包失败解决方法

go get golang.org/x 包失败解决方法

由于墙的原因,国内使用 go get安装golang 官方包可能会失败

解决方法

方法1 [不需要FQ]

Win10下相关配置:
GOPATH : E:\go

安装记录:

E:\>go get -u -v golang.org/x/crypto/...
Fetching https://golang.org/x/crypto?go-get=1
https fetch failed: Get https://golang.org/x/crypto?go-get=1: dial tcp 216.239.37.1: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.
package golang.org/x/crypto/...: unrecognized import path "golang.org/x/crypto/..." (https fetch: Get https://golang.org/x/crypto?go-get=1: dial tcp 216.239.37.1: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.)

E:\>mkdir %GOPATH%\src\golang.org\x
E:\>cd %GOPATH%\src\golang.org\x
E:\go\src\golang.org\x>git clone https://github.com/golang/crypto.git

E:\go\src\golang.org\x>go install golang.org/x/crypto
can't load package: package golang.org/x/crypto: no Go files in E:\go\src\golang.org\x\crypto

E:\go\src\golang.org\x>go install golang.org/x/crypto/...
crypto\blake2b\blake2bAVX2_amd64.go:9:8: cannot find package "golang.org/x/sys/cpu" in any of:
        C:\Go\src\golang.org\x\sys\cpu (from $GOROOT)
        E:\go\src\golang.org\x\sys\cpu (from $GOPATH)
crypto\ssh\terminal\util_windows.go:22:2: cannot find package "golang.org/x/sys/windows" in any of:
        C:\Go\src\golang.org\x\sys\windows (from $GOROOT)
        E:\go\src\golang.org\x\sys\windows (from $GOPATH)
        
E:\go\src\golang.org\x>go get -u -v golang.org/x/sys
Fetching https://golang.org/x/sys?go-get=1
https fetch failed: Get  

E:\go\src\golang.org\x>git clone https://github.com/golang/sys.git
E:\go\src\golang.org\x>go install golang.org/x/sys/...
E:\go\src\golang.org\x>go install golang.org/x/crypto/...
E:\go\src\golang.org\x>ls E:\go\pkg\windows_amd64\golang.org\x
crypto  sys

1) 需要FQ,设置http代理

windows下:

set http_proxy=代理ip:port (临时有效)
set HTTPS_PROXY=代理ip:port (临时有效)
set ALL_PROXY=代理ip:port(临时有效)

linux下:

export http_proxy=代理ip:port (临时有效)
export HTTPS_PROXY=代理ip:port (临时有效)
或者合成一条
export ALL_PROXY=代理ip:port (临时有效)

这里使用的是shadowsock5配合cow
cow github地址
cow release地址

E:\go>ls
cow-win64-0.9.8
E:\go>cd cow-win64-0.9.8
E:\go\cow-win64-0.9.8>mv rc.txt rc.txt_bak
# 手动修改rc.txt,修改后内容如下
E:\go\cow-win64-0.9.8>cat rc.txt
listen = http://127.0.0.1:7777
proxy = socks5://127.0.0.1:1080
E:\go\cow-win64-0.9.8>cow.exe rc.txt -request -reply -v
2017/06/29 22:58:00 COW 0.9.8 listen http 127.0.0.1:7777, PAC url http://127.0.0.1:7777/pac

#打开命令一个cmd终端(curl需要自行安装,并添加入环境变量PATH中)
E:\>curl https://www.google.com
curl: (7) Failed to connect to www.google.com port 443: Timed out
# 方式1: 直接通过`-x`指定代理
E:\> curl -x http://127.0.0.1:7777 www.google.com
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" ht
....
# 方式2: 设置http/https代理,注意http_proxy是小写,HTTPS_PROXY是大写
E:\>set http_proxy=http://127.0.0.1:7777
E:\>set HTTPS_PROXY=http://127.0.0.1:7777
E:\> curl www.google.com
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" ht
....

# 此时原终端显示
E:\go\cow-win64-0.9.8>cow.exe -request -v
2017/06/29 23:17:59 COW 0.9.8 listen http 127.0.0.1:7777, PAC url http://127.0.0.1:7777/pac
[>>>>>] 2017/06/29 23:18:08 cli(127.0.0.1:5502) request  CONNECT www.google.com:443
CONNECT www.google.com:443 HTTP/1.1
Host: www.google.com:443
User-Agent: curl/7.55.1
Connection: keep-alive

[>>>>>] 2017/06/29 23:18:31 cli(127.0.0.1:5544) request  CONNECT www.google.com:443
CONNECT www.google.com:443 HTTP/1.1
Host: www.google.com:443
User-Agent: curl/7.55.1
Connection: keep-alive
# 说明cow http代理成功

# cow启动正常后,即可成功安装crypto 
E:\>go get -u -v golang.org/x/crypto/...
Fetching https://golang.org/x/crypto?go-get=1
Parsing meta tags from https://golang.org/x/crypto?go-get=1 (status code 200)
get "golang.org/x/crypto": found meta tag get.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at https://golang.org/x/crypto?go-get=1
golang.org/x/crypto (download)
...
get "golang.org/x/sys/windows": verifying non-authoritative meta tag
golang.org/x/sys/windows
golang.org/x/crypto/ssh/terminal
# 成功安装
于墙的原因,国内使用goget安装golang官方可能会失败解决方法方法1[不需要FQ]Win10下相关配置:GOPATH:E:\go安装记录:E:\>gogetuvgolangorg/x/
由于某些不可抗力的原因,国内使用goget命令安装时会经常会出现timeout的问题。本文介绍几个常用的解决办法。从github克隆golang在github上建立了一个镜像库,如https://g
前言:随着go111的发布,go官方引入了gomodule来解决依赖管理问题,gomodule被集成到原生的gocmd中,但是如果你的代码库在$GOPATH中,go111的module功能是默认不会
安装golanggithubcom/hyperledger/fabriccontractapigo依赖的时候,长时间无响应,最后报如下错误:go:githubcom/hyperledger/fabr
使用标准库http来实现packagetoolsimport(io/ioutilnet/http)funcGet(urlstring)string{res,err:httpGet(url)iferr!
在开发过程中可能会遇到这样的情况,有一些是引入自不同地方的,比如:golangorg/x/net/html和net/html,golangorg/x/crypto和crypto。那这是什么原因呢?
首先尝试了配置goenvwGOSUMDBsumgolanggooglecn,发现还是有问题,只是换个访问不了的IP而已。后期改成了配置环境变量,新增GOPROXY值为https://goproxyio
olangx(type)用法类型断言和类型判断if和typeswitch两种形式使用类型断言断定某个接口是否是指定的类型if这种简化形式:if_,ok:x(T);ok{}typeswitch类型判断
在配置了环境变量$GOPATH后,比如下面这个路径exportGOPATH/mnt/f/ubuntu/goProject在这个路径下面会有这几个目录在src目录下放着我的源码比如:在同一个目录下,比如
文章目录为什么需要ReadWriter对象Reader对象基础概念创建Reader对象操作Reader对象Writer对象基础概念创建Writer对象操作Writer对象为什么需要在Go语言中,几乎所