Package Management in Go for NPM users


Installing a Dependency

Similar to npm install you have go get url@version.

After installing a dependency, if you look at the go.mod file, you might see some of the dependencies listed as // indirect

When you install a package, you might see that it created go.sum file in the repository which contains the cryptographic checksums of the packages installed which is used for validation purposes.

Caching the dependencies

Running go mod download will download all the dependencies and cache them locally which could make CI faster.

Removing unused packages

Updating Package Versions

Substituing Imported Modules

Point a required module to your own fork or even local file path using replace directive:

go mod edit -replace

Remove the replacement

go mod edit -dropreplace