Tag Modules

`replace` directive in go modules
1 min read

Sometimes, we may want to use a library but a slightly modified version. It happens very often when we develop the library but test it in the context of an application. Go has a handy mechanism in go modules that can help us with it.

To make it work, we have to clone the library somewhere near the target project and run the following command in the application’s folder.

go mod edit -replace github.com/my/library ../path

The path can be both relative (to the application root folder) or absolute. The go.mod file will be edited as follows.

Golang Tips & Tricks #7 - private repository and proxy
1 min read

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.