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/[email protected]
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
To create a release follow this checklist:
- Run
go mod tidy
on master. If there are changes, create a branch and PR them. - Create a git tag on master branch (after above changes are merged).
It is important that the tag is created on master branch. You can use
git tag -as $TAG
orgit tag -s -m "$RELEASE_MESSAGE"
. - Congratulations, you are done with creating a release.
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