Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"go get" ignores GOPROXY when using http_proxy

Tags:

proxy

go

I'm trying to get Go to use an internal enterprise Go-Proxy for module download - which requires an http_proxy to be accessible (enterprise firewall). However go get -u golang.org/x/lint/golint fails:

package golang.org/x/lint/golint: unrecognized import path "golang.org/x/lint/golint": https fetch: Get "https://golang.org/x/lint/golint?go-get=1": Forbidden

My setup:

  • http_proxy and https_proxy environment variables are set
  • no_proxy does not contain the IP or hostname of my Go-Proxy
  • GOPROXY is set (go env -w GOPROXY=https://artifactory.mycompany.com/api/go/myrepo-go-virtual)

I checked:

  • Using curl and directly querying the GOPROXY server works fine and I can download the file (so the https_proxy setting works)
  • Counter-check with curl and explicitly unsetting http/https_proxy: No connection, as expected

Using tcpdump, I discovered that running go get seems to ignore my GOPROXY and ask my http_proxy to connect directly to the original url on golang.org (Options/sequence and ack numbers omitted for brevity), which the proxy/firewall blocks.

06:52:53.926397 IP <my_ip.port> > <proxy.port>: Flags [S], length 0
06:52:53.927206 IP <proxy.port> > <my_ip.port>: Flags [S.], length 0
06:52:53.927232 IP <my_ip.port> > <proxy.port>: Flags [.], length 0
06:52:53.932003 IP <my_ip.port> > <proxy.port>: Flags [P.], length 89: HTTP: CONNECT golang.org:443 HTTP/1.1
06:52:53.932638 IP <proxy.port> > <my_ip.port>: Flags [.], length 0
06:52:53.933100 IP <proxy.port> > <my_ip.port>: Flags [P.], length 3939: HTTP: HTTP/1.1 403 Forbidden

Question: Why does Go ignore the GOPROXY? Did I not set something up correctly?

I'm using Go 1.15.3 in the golang:1.15.3 Docker container (with some added tools to check connectivity)

like image 286
Patrick Avatar asked Oct 24 '25 05:10

Patrick


1 Answers

Try this: set GO111MODULE=on to use GOPROXY Or run go mod init before you run go get

like image 117
ws_ Avatar answered Oct 27 '25 01:10

ws_