由于墙的原因,国内使用 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. Codeforces 978E:Bus Video System

    题目链接:http://codeforces.com/problemset/problem/978/E 题意 一辆公交车,在每站会上一些人或下一些人,车的最大容量为w,问初始车上可能有的乘客的情况数. ...

  2. Java异常处理的方法

    1.异常概述在程序中,错误可能产生于程序员没有预料到的各种情况,或者是超出了程序员可控制范围的环境因素,如用户的坏数据.试图打开一个根本不存在的文件等.在Java中这种在程序运行是可能出现的一些错误称 ...

  3. 基于PaaS和SaaS研发平台体系

    基于PaaS和SaaS研发的商业云平台实战 背景介绍 SaaS.PaaS.IaaS等云服务模式已经被大家普遍认可,在研发过程中借力一些PaaS和SaaS平台,能够提升产品的研发速度和功能稳定程度.本文 ...

  4. LeetCode - Diameter of Binary Tree

    Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a b ...

  5. LeetCode – All Nodes Distance K in Binary Tree

    We are given a binary tree (with root node root), a target node, and an integer value K. Return a li ...

  6. 【HAOI2011】problem a

    又看题解了,这样下去要跪啊QAQ 原题: 一次考试共有n个人参加,第i个人说:“有ai个人分数比我高,bi个人分数比我低.”问最少有几个人没有说真话(可能有相同的分数) 1≤n≤100000   0≤ ...

  7. MySQL Binlog常用参数

    ====================================================================== MySQL Binlog常用参数 log_bin 设置此参 ...

  8. scala函数等号省略

    例1: 此时没有写返回值,但是有等号,函数会自己推断返回值,此时的返回值是Int def add(x:Int, y:Int) = { x+y} 例2: 此时没有写返回值,也没有等号,无论函数内部有没有 ...

  9. Generic Realtime Intermediary Protocol

    转自:https://pushpin.org/docs/protocols/grip/ Introduction The Generic Realtime Intermediary Protocol ...

  10. mysql——创建索引、修改索引、删除索引的命令语句

    查看表中已经存在 index:show index from table_name; 创建和删除索引索引的创建可以在CREATE TABLE语句中进行,也可以单独用CREATE INDEX或ALTER ...