gogithubgo-get

Why does “go get” sometimes retrieve an outdated commit?


I have created a Go module and put it at github.com/bronger/abcde. Erroneously, I declared it in its go.mod as module abcde. Therefore, a go get github.com/bronger/abcde in a Dockerfile (i.e. without my local copy of the program) fails with

#10 0.824 go: downloading github.com/bronger/abcde v0.0.0-20210813180406-8d5688e6c805                                                 #10 0.866 go get: github.com/bronger/abcde@none updating to
#10 0.866       github.com/bronger/abcde@v0.0.0-20210813180406-8d5688e6c805: parsing go.mod:
#10 0.866       module declares its path as: abcde
#10 0.866               but was required as: github.com/bronger/abcde

So I corrected the module name in go.mod and pushed the result.

Eventually, this works. However, it may take a long time (30–60 minutes) before go get finally detects the change. The latest incorrect commit is 8d5688e, which also occurs in the error message above. Even many minutes after 80c407b is the latest commit on GitHub, go get still complaints about 8d5688e.

Why is this?


Solution

  • By default, the Go tools use a proxy provided by the Go Team. This means that changes to modules can be cached for a certain period. You'll be able to find more information about that on their website: https://proxy.golang.org/.

    Setting GOPROXY=off as an environment variable will disable the use of this proxy.