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

解决方法

方法1 [不需要翻墙]

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) 需要翻墙,设置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
# 成功安装

go get golang.org/x 包失败解决方法的更多相关文章

  1. go get 安装一个特定版本的包失败解决方法

    场景描述 go get 下载第三方包golang gin框架时,会去下载gopkg.in/go-playground/validator.v8包以及gopkg.in/yaml.v2包,gopkg.in ...

  2. npm install 包 失败解决方法

    在ionic 安装包的时候 npm install xxx --save 出现如下错误 查看日志文件 14 verbose stack SyntaxError: Unexpected token &l ...

  3. docker load tar.gz包失败解决方法

    执行docker load -i xxx.tar.gz时候报错 open /var/lib/docker/xxx No such file or directory 这种情况属于容器快照文件缺乏基础镜 ...

  4. Docker安装、命令详情、层级架构、docker服务启动失败解决方法

    容器背景: 层级架构:  容器对比传统化虚拟机: 可以把docker理解成是一款自带软件(比如:nignx.tomcat.....)的镜像操作系统(首先是要下载镜像) 以下是Windows环境安装Do ...

  5. R语言—如何安装Github包的解决方法,亲测有效

    R语言—如何安装Github包的解决方法,亲测有效 准备安装材料: R包-REmap GitHub下载地址:https://github.com/lchiffon/REmap R包-baidumap ...

  6. Win10 连接L2TP VPN 失败解决方法

    Win10 连接L2TP VPN 失败解决方法 iOS系统不知道在什么时候,已经不支持PPTP VPN.偶尔的机会刚好看到github上的一键式VPN服务器部署脚本setup-ipsec-vpn,就在 ...

  7. 用户 NT AUTHORITY\NETWORK SERVICE 登录失败 解决方法(转载)

    用户 NT AUTHORITY\NETWORK SERVICE 登录失败 解决方法 (MS SQL 2005) Windows server 2003,2008 Web.Config 配置连接sql ...

  8. 检索 COM 类工厂中 CLSID 为 {10020200-E260-11CF-AE68-00AA004A34D5} 的组件时失败,解决方法如下:

    检索 COM 类工厂中 CLSID 为 {10020200-E260-11CF-AE68-00AA004A34D5} 的组件时失败,解决方法如下: 第 一步:首先将msvcr71.dll,  SQLD ...

  9. nfs文件系统挂载失败解决方法

    nfs文件系统挂载失败解决方法 */--> nfs文件系统挂载失败解决方法 Table of Contents 1. 错误提示 2. 我的配置 1 错误提示 bootserver=255.255 ...

随机推荐

  1. 陕西师范第七届I题----排队

    链接:https://www.nowcoder.com/acm/contest/121/I来源:牛客网 题目描述 ACM竞赛队内要开运动会啦!!!! 竞赛队内的一群阳光乐观积极的队员们迅速的在操场上站 ...

  2. Python字符集

    字符集: 美国:ASCII      需要8bit表示     英文字母一个字节,不支持中文中国:GBK                           英文字母一个字节,汉字占两个字节万国:un ...

  3. 实验吧—Web——WP之 简单的sql注入之2

    直接打开解题连接: 既然是SQL注入,那么我们就要构造注入语句了,这个就要有耐心一个一个去尝试了 输入语句 1'and 1=1 # 和 1'and/**/1=1/**/#后 对比一下,发现是过滤掉了空 ...

  4. json(传输格式)、异步加载、时间线

    xml:过去传输的数据格式 json:现在的传输数据格式,属性名加双引号来区别,其实也是对象,传输的是个字符串,其实就是json 前端JSON.stringfy(obj) 然后传给后台 后台传回来的j ...

  5. LeetCode - Minimum Area Rectangle

    Given a set of points in the xy-plane, determine the minimum area of a rectangle formed from these p ...

  6. DBUtils和连接池

    今日内容介绍 1.DBUtils 2.连接池 ###01DButils工具类的介绍个三个核心类 * A: DButils工具类的介绍个三个核心类 * a: 概述 * DBUtils是java编程中的数 ...

  7. oracle使用flashback时,没有显示undosql

    这是因为oracle11g没有开启这个功能 用管理员用户sys(也就是sysdba)执行以下语句即可 alter databases add supplemental log data; 如果我们想恢 ...

  8. Running Elixir in Docker Containers

    转自:https://www.poeticoding.com/running-elixir-in-docker-containers/ One of the wonderful things abou ...

  9. sqler sql 转rest api 的docker image

    最新sqler 又发布了一个版本,同时官方文档也更新,对于数据库的连接有了详细的说明 Dockerfile 为了方便以及减少大小,使用多阶段构建,同时都通过环境变量运行 FROM alpine:lat ...

  10. day28 1.缓冲区 2.subprocess 3.黏包现象 4.黏包现象解决方案 5.struct

    1.缓冲区: 输入缓冲区  输出缓冲区 2. subprocess的使用import subprocess sub_obj = subprocess.Popen('ls', #系统指令shell=Tr ...