bd is a simple tool for managing Go binary dependencies. It allows you to specify the required tools, their versions, and target installation directory in a configuration file (bd.json).
- Ensures consistent versions of binaries across environments.
- Installs binaries to a dedicated directory, preventing pollution of global
GOBIN. - Supports custom binary names with version suffixes.
- Avoids dependency conflicts often encountered with
tools.go. - Provides an easy way to execute installed binaries with
bd exec.
# Clone the repository and build manually, or install using go install
go install github.com/afansv/bd@latest{
"binDir": "bin",
"binaries": [
{ "package": "golang.org/x/tools/cmd/goimports", "version": "latest", "name": "goimports" },
{ "package": "github.com/mgechev/revive", "version": "v1.3.0", "name": "revive" }
]
}Note: It is recommended to specify exact versions instead of
latestto ensure reproducible environments.
Also, you can set Go version for specific package via toolchain property:
{
"binDir": "bin",
"binaries": [
{
"package": "github.com/golangci/golangci-lint/cmd/golangci-lint",
"version": "v1.63.4",
"name": "golangci-lint",
"toolchain": "go1.23.5"
}
]
}bd installThis will install the specified binaries into binDir, appending their versions to the filenames.
Note: You can use
--clean,-cleanor-coption to cleanbinDirbefore installing.
bd exec goimports -w main.goIf the binary is not found, bd will suggest running bd install first.
Alternatively, you can run binaries directly from binDir:
./bin/goimports -w main.go- Keeps your project’s tooling self-contained, avoiding version conflicts.
- Works without modifying
go.modor relying ontools.go. - Ensures team-wide consistency in CI/CD and local development.
- Store
bd.jsonin the repository. It should not be added to.gitignore. - The
binDirdirectory should be added to.gitignoreto avoid committing installed binaries.
MIT
