Golang Tips & Tricks #7 - private repository and proxy
Buy me a coffeeBuy me a coffee


In Go 1.13 all modules are provided using a proxy. The proxy caches dependencies what helps to make sure that the version of an external dependencies will never change. If the vendor remove the version and create a new one with the same version, only the first one will be provided. Proxy improves the performance of downloading dependencies as well so it’s useful to have such functionality in the ecosystem.

The problem starts when you use a private dependency which cannot be cached using public cache. To control this behavior and exclude some dependencies from caching, the GOPRIVATE env variable should be used.

export GOPRIVATE=mycorp.com/*

It says that all dependencies which start with mycorp.com/ will miss the public cache. If your company host code on GitHub, you can set this variable to:

export GOPRIVATE=github.com/yourcorp/*

This will make sure that all private company repos hosted on GitHub will miss the public proxy.

Tags: #golang #modules #proxy

See Also