3

I am in China and I am compiling a program on linux. The problem is that golang related things are blocked in China. I have tried many proxies but I can't find a solutuion. Can some one please explain me where to manually put this file. I can open it in browser but i don' know where to place it.

go: github.com/onsi/gomega@v1.17.0: Get "https://proxy.golang.org/github.com/onsi/gomega/@v/v1.17.0.mod": dial tcp 172.217.163.49:443: i/o timeout go: downloading github.com/pkg/errors v0.9.1

2 Answers2

4

As an example to use a proxy, you can refer to this repo which is used for china Gophers and you can check the documentation on this site. you may use another proxy link but the method is the same.

  • macOS or Linux

Open your terminal and execute

$ export GO111MODULE=on
$ export GOPROXY=https://goproxy.cn

or

$ echo "export GO111MODULE=on" >> ~/.profile
$ echo "export GOPROXY=https://goproxy.cn" >> ~/.profile
$ source ~/.profile

done.

  • Windows

Open your PowerShell and execute

C:\> $env:GO111MODULE = "on"
C:\> $env:GOPROXY = "https://goproxy.cn"

if you want to make exceptions you can try:-

# Set the GOPROXY environment variable
export GOPROXY=https://goproxy.io,direct
# Set environment variable allow bypassing the proxy for specified repos (optional)
export GOPRIVATE=git.mycompany.com,github.com/my/private
MSH
  • 395
  • 1
  • 4
  • 13
0
$ export GO111MODULE=on
$ export GOPROXY=https://goproxy.cn

This works for me. Thanks a lot.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 20 '23 at 13:00