Getting dependencies via GOPROXY

I recently wanted to use a private registry in a go project.

It can be for many reasons:

  • ensure immutability from one built to another
  • ensure avaibility of a build (remember npm author who removed his library and broke half the internet?)
  • get non-public library

How it works

Quick & Easy

It is super easy you just have to add an env variable:

export GOPROXY=""

You can then do a:

go env

To see if it was applied.

Does it really work?

Then I was curious to know if it really worked or not?

I tried verbose but it wouldn’t show me the registry.
I then tried:

go get -v -t

But it will give me an answer if a version doesn’t exist:

go get: invalid version: reading  http://.com 404 Not found


This is what I was looking for:

go get -v -x <package>

It will show where it’s taken from:

$ go get -v -x
# get
# get
# get