Go Modules introduce new way to manage dependencies but also new hurdles of using them. In here we will gather knowledge, tools and other bits to ease up use of go modules.
To simply update dependency to newer tagged version:
go get github.com/ipfs/go-cid@v0.0.2
It is not required to update all after a new version is released. In general update update modules that use the new functionality or require fixes.
Use local replace directives for developing. Example:
replace github.com/ipfs/go-cid => ../go-cid
To test out in CI, commit and push the dependency to a branch and then run:
go get github.com/ipfs/go-cid@$HASH
to update the version. You can also replace $HASH
with branch name.
If for some reason version in the build did not change (caused by off master tags). Use replace directive like this:
replace github.com/ipfs/go-cid => github.com/ipfs/go-cid@$HASH
Here is a config for Travis CI: travis.example.yml
The pre-commit hook will alert you, when you are trying to commit go.mod file with local replace directives. This is useful pattern for developing but has no place on remote.
It is best to install it as global githook. Instructions here