Search code examples
godependency-managementgo-modulesgo-packages

Originating proxy of downloaded module


Say you are using Go 1.13 and set up a project initialized for Go Modules.

$ mkdir my-project
$ cd my-project
$ git mod init github.com/bmuschko/my-project

Instead of using the default Google proxy to download dependencies, you set GoCenter or a different proxy.

$ export GOPROXY=https://gocenter.io

Once you download dependencies, it doesn't seem that Go keeps track of the originating proxy. In the end, there's no way to know or verify that a dependency came from the Google proxy, a custom proxy or directly from the source code repository. In theory, the checksums could be different depending on the originating proxy if you switch between them even if you pull the same version.

$ go get github.com/spf13/cobra

Does Go store this information somewhere in the cache? I couldn't find this information. Any advice would be appreciated.


Solution

  • The originating proxy should not matter and is not recorded: if you have downloaded the module from anywhere, then the bytes in your module cache should match the checksum found in either your go.sum file or the global checksum database.

    (The go command fetches checksums for any new module dependencies from the database before downloading the module or adding the checksum to your go.sum file.)