Search code examples
gogo-modulesgo-toolchain

Get registry info regarding where dependencies are coming from


I would like to get my dependencies from a private golang registry.

By using GOPROXY.

I would like to make sure all dependencies are coming from that private registry.

The only way I found for now is by doing

go get -v -t  github.com/opentracing/opentracing-go@fakeversion

Which will return

go get: github.com/opentracing/opentracing-go@fakeversion: invalid version: reading  http://myprivateregistry.com 404 Not found

How can I get the registry it's taken from without doing that?


Solution

  • You can trace go get with go get -v -x <package> (can omit -v) and check that the requests match your expectations:

    $ go get -v -x
    # get https://myinternalproxy.com/github.com/@v/list
    # get https://myinternalproxy.com/github.com/gin-gonic/gin/@v/list
    # get https://myinternalproxy.com/github.com/gin-gonic/@v/list
    # get https://myinternalproxy.com/github.com/stretchr/testify/require/@v/list
    # get https://myinternalproxy.com/github.com/stretchr/testify/assert/@v/list
    # get https://myinternalproxy.com/github.com/stretchr/testify/@v/list
    # get https://myinternalproxy.com/github.com/stretchr/@v/list
    # get https://myinternalproxy.com/github.com/stretchr/@v/list: 410 Gone (0.462s)
    # get https://myinternalproxy.com/github.com/gin-gonic/@v/list: 410 Gone (0.466s)
    # get https://myinternalproxy.com/github.com/@v/list: 410 Gone (0.466s)
    ... much more logs