Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Gotools

This directory contains Go-based tools to use with go tool.

Each tool is within its own directory with its own go.mod file to avoid dependency conflicts.

Managing tools

Using a tool

go tool -modfile <path to modfile> <tool>

For example, to use mockgen:

go tool -modfile gotools/mockgen/go.mod mockgen -h

Add a new tool

From repository root:

TOOLNAME=<tool name>
mkdir -p gotools/"$TOOLNAME"
go mod init -modfile=gotools/"$TOOLNAME"/go.mod github.com/rancher/fleet/gotools/"$TOOLNAME"
go get -tool -modfile=gotools/"$TOOLNAME"/go.mod <module>@<version>

For example, mockgen was added this way:

TOOLNAME=mockgen
mkdir -p gotools/"$TOOLNAME"
go mod init -modfile=gotools/"$TOOLNAME"/go.mod github.com/rancher/fleet/gotools/"$TOOLNAME"
go get -tool -modfile=gotools/"$TOOLNAME"/go.mod go.uber.org/mock/mockgen@v0.6.0

Update existing tool

From repository root:

TOOLNAME=<tool name>
go get -tool -modfile=gotools/"$TOOLNAME"/go.mod <module>@<new version>

For example, to update mockgen to v0.6.0:

TOOLNAME=mockgen
go get -tool -modfile=gotools/"$TOOLNAME"/go.mod go.uber.org/mock/mockgen@v0.6.0