我有GoLang
go version go1.10.3 windows/amd64
在我们的公司网络中,只能通过代理访问Internet。
在git客户端中确实设置了
git config --global http.proxy http://user:password@proxy:8118
确实做到了这一点
c:\go\bin\go get -u -v github.com/prometheus/client_golang/prometheus
但是如果在新的pkg中确实具有依赖项,例如
C:\Windows\system32>c:\go\bin\go get -u -v github.com/prometheus/common/log
github.com/prometheus/common (download)
github.com/sirupsen/logrus (download)
Fetching https://golang.org/x/crypto/ssh/terminal?go-get=1
https fetch failed: Get https://golang.org/x/crypto/ssh/terminal?go-get=1: dial tcp 193.184.73.141:4
43: connectex: No connection could be made because the target machine actively refused it.
package golang.org/x/crypto/ssh/terminal: unrecognized import path "golang.org/x/crypto/ssh/terminal
" (https fetch: Get https://golang.org/x/crypto/ssh/terminal?go-get=1: dial tcp 193.184.73.141:443:
connectex: No connection could be made because the target machine actively refused it.)
Fetching https://golang.org/x/sys/windows/svc/eventlog?go-get=1
https fetch failed: Get https://golang.org/x/sys/windows/svc/eventlog?go-get=1: dial tcp 193.184.73.
141:443: connectex: No connection could be made because the target machine actively refused it.
package golang.org/x/sys/windows/svc/eventlog: unrecognized import path "golang.org/x/sys/windows/sv
c/eventlog" (https fetch: Get https://golang.org/x/sys/windows/svc/eventlog?go-get=1: dial tcp 193.1
94.173.141:443: connectex: No connection could be made because the target machine actively refused it
.)
Fetching https://gopkg.in/alecthomas/kingpin.v2?go-get=1
https fetch failed: Get https://gopkg.in/alecthomas/kingpin.v2?go-get=1: dial tcp 135.186.143.184:443
: connectex: No connection could be made because the target machine actively refused it.
package gopkg.in/alecthomas/kingpin.v2: unrecognized import path "gopkg.in/alecthomas/kingpin.v2" (h
ttps fetch: Get https://gopkg.in/alecthomas/kingpin.v2?go-get=1: dial tcp 135.186.143.184:443: connec
tex: No connection could be made because the target machine actively refused it.)
如果依赖项尝试从Internet下载,如何配置代理?
答案 0 :(得分:2)
您需要像设置git一样设置http_proxy环境。
尝试运行set http_proxy=http://user:password@proxy:8118
,然后运行go get
命令