rss twitter gitlab github linkedin linkedin instagram
Go Tool: retool
Apr 17, 2019

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 counterfeiter or 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.


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 $GOPATH/
cd $GOPATH/ && git checkout tags/v1.3.7
go get

Using it

The workflow to enable retool using the tool is the following: assuming we want to use counterfeiter version v6.0.1 we will do the following to add this version of this tool:

retool add 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 \
  add v6.0.1

Back to posts