Add A Go Tool
Go-installed tools are managed via a list.
Preconditionsโ
- Go is installed.
- You verified the module path for the tool.
Stepsโ
-
Add the module path to:
This installs as
~/.default-golang-pkgs. The file is a chezmoi template, so entries can be gated on OS or architecture. -
Apply:
chezmoi apply
Hook:
home/.chezmoiscripts/run_onchange_after_05-update-golang-pkgs.sh.tmpl- Reconcile helper:
scripts/reconcile_golang_pkgs.py
Verificationโ
which <tool>
<tool> --version
Rollback / Undoโ
- Remove the module path from
home/readonly_dot_default-golang-pkgs.tmpl. - Re-apply:
chezmoi apply
Reconciliation rules:
| Rule | Detail |
|---|---|
| Removed module | its binary is deleted from GOBIN on the next apply |
| Safety ledger | ~/.cache/chezmoi/golang-pkgs-state records binaries this tooling installed |
| Hand installs | binaries installed manually with go install are left untouched |
| Install detection | checks the binary in GOBIN (go env GOBIN, else $(go env GOPATH)/bin) |
| Not used | go list -m all, because it does not enumerate installed binaries |