Skip to main content

Command Palette

Search for a command to run...

About GitHub repos and the Go module proxy server

Updated

I recently did some work that involved updating a repository containing a Go module, and then installing that module as a dependency in a different Go project. This involved a couple of mildly unusual workflows, including installing a specific branch of a GitHub repo as a dependency, and verifying module updates were pushed to the Go module proxy server. I'm largely writing this post so that, if I ever have to do this again, hopefully my own post will show up when I google this problem.

First, installing a branch as a dependency. This is actually very straightforward. You just need to go get github.com/organization/repo@my-branch. This bypasses the module proxy altogether and builds the dependency from the target branch. Useful for testing feature work.

But then, if your case is like mine, you need to merge that feature work into main and update your dependencies again -- and you'll probably want to do this without targeting a specific branch. This means your go get command will likely go through the Go module proxy server. The FAQ for this server is useful. In my case, I just wanted to make sure that I was getting the latest version of my dependency, but the proxy server doesn't fetch module updates in realtime. So here's what you can do:

  1. Note that you can see which versions of a module are available on the proxy server with this URL: https://proxy.golang.org/github.com/organization/repo/@v/list. You'll see versions that correspond to your GitHub tags.
  2. Push up a new GitHub tag with your latest changes
  3. Wait for the proxy server to update, checking with the URL from step 1.
  4. If you don't feel like waiting, you can go get github.com/organization/repo@v1.0.0 or whatever your tag is.
  5. Verify with the URL from step 1 that the proxy server has updated.
  6. At this point, go get github.com/organization/repo should pull the latest version from the proxy server.
42 views