dept icon indicating copy to clipboard operation
dept copied to clipboard

Go tool management based on Go modules

dept

CircleCI codecov

Go modules based dependency management for Go tools.

Description

dept is a dependency management tool based on Go modules.
Instead of go.mod, dept helps you to manage Go tools. Go tools like Golint, errcheck are often used in various environment. dept provides you deterministic builds by manage tool dependencies.

dept is based on Go modules. All dependency resolution are provided by go mod commands.

Requirements

  • Go v1.13 or later

Basic usage

At first, let's create gotool.mod in a project root by the following command. All tools which are managed by dept are written to gotool.mod.

$ dept init

Then, let's install Go tools you want to use in your project.

$ dept get github.com/mitchellh/gox github.com/tcnksm/[email protected]
$ dept get -o lint github.com/golangci/golangci-lint/cmd/golangci-lint # rename golangci-lint as 'lint'

Finally, use exec to execute installed commands.

$ dept exec ghr -v
ghr version v0.12.0

If you want to installed commands without dept, please run build.

$ dept build
$ ls _tools
ghr     gox     lint

Available commands

init

$ dept init

get

dept get installs binaries to the specified directory.

$ dept get github.com/mitchellh/gox 

You can select the specified version like Go modules:

$ dept get github.com/mitchellh/[email protected]
$ dept get github.com/mitchellh/[email protected]

To install a binary with another name:

$ dept get -o lint github.com/golangci-lint/cmd/golangci-lint

Update tools to the latest version:

$ dept get -u github.com/mitchellh/gox
$ dept get -u # update all tools

remove

dept remove uninstalls passed tools.

$ dept remove github.com/mitchellh/gox

exec

dept exec executes the passed tool with arguments.

$ dept exec ghr -v

build

dept build builds all tools.

$ dept build

If $GOBIN enabled, it will be used preferentially.

$ GOBIN=$PWD/bin dept build

Also, -d flag is provided.

$ dept build -d bin

list

dept list list ups all tools managed by dept.

$ dept list
github.com/golangci/golangci-lint/cmd/golangci-lint lint v1.12.3
github.com/mitchellh/gox gox v0.4.0
github.com/tcnksm/ghr ghr v0.12.0

You can format output with -f flag.

$ dept list -f '{{ .Name }}'
lint
gox
ghr

clean

dept clean cleans up all cached tools.

$ dept clean