One of toughest things in Go is versioning, for library dependencies there are different ways to handle this, vendoring automatically using a tool like
dep, which is the de facto most popular tool for doing so, or using modules, which happens to be the new official workflow.
For tools that you depend on, for example for generating code (like
go-swagger) or linters (like
golangci-lint), things get a bit more complicated, sure you could hack your
PATH to point to different versions and use docker for wrapping those commands and specific versions; but that is definitely messy and not sustainable in the long run.
However, assuming the tools you depend on are written in Go, you should definitely use
retool is a tool for vendoring concrete Go programs’ versions that are not imported by your code.
This is a bit an egg-chicken situation, it is because to date
retool does not support Go modules, so to install it you would need to explicitly use the usual trick, assuming you want to install
v1.3.7 you would do something like the following:
git clone email@example.com:twitchtv/retool.git $GOPATH/github.com/twitchtv/retool cd $GOPATH/github.com/twitchtv/retool && git checkout tags/v1.3.7 go get github.com/twitchtv/retool
The workflow to enable
retool using the tool is the following: assuming we want to use
v6.0.1 we will do the following to add this version of this tool:
retool add github.com/maxbrunsfeld/counterfeiter v6.0.1
Then doing something like
retool counterfeiter would allow you to call this vendored tool. If we are planning to use a forked tool, then doing something like the following will work:
retool -f firstname.lastname@example.org:something/go-counterfeiter \ add github.com/maxbrunsfeld/counterfeiter v6.0.1