Skip to Content
DocumentationDocumentationProvidersgo install

go install Provider

Wraps go install for installing Go-based CLI tools from source. If you write Go, you already know the drill — go install github.com/x/y@latest drops a binary into $GOBIN. hams records the fact so you can reproduce it later.

Platforms: macOS, Linux

Usage

# Install (full import path) hams goinstall install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest # No version? hams defaults to @latest hams goinstall install github.com/goreleaser/goreleaser # See what hams is managing hams goinstall list

go install doesn’t have a native “uninstall” — to remove, hams deletes the matching binary from $GOBIN.

Hamsfile example

# macOS/goinstall.hams.yaml schema_version: 1 provider: goinstall groups: - tag: go-tools items: - app: github.com/golangci/golangci-lint/v2/cmd/golangci-lint version: latest intro: Go linter aggregator. - app: golang.org/x/tools/cmd/goimports intro: Go import organizer. - app: github.com/goreleaser/goreleaser version: v1.25.1 intro: Go release tool.
  • app is the full import path — same shape you’d hand to go install
  • version is optional; skip it and you get latest. Pin a tag to freeze the version

How state is probed

Go has no native “list my globally-installed tools” command (because go install is stateless). hams’s workaround:

  1. Scan $GOBIN (defaults to $GOPATH/bin, or ~/go/bin if $GOPATH isn’t set)
  2. For each binary, run go version -m <bin> to read its embedded module info
  3. Match those against the import paths declared in the Hamsfile

So even on a machine packed with random Go binaries, hams only claims the ones it’s actually managing.

Bootstrap

You need go itself. Easiest path is Homebrew or apt:

# Homebrew.hams.yaml - app: go intro: Go programming language.

Then make sure Homebrew (or apt) comes before goinstall in provider_priority.

@latest and versioning

go install x@latest hits the module proxy each time to fetch the newest release. hams records the actual version installed into .state/. So on subsequent applies, as long as the Hamsfile says latest and there’s a state entry, hams won’t re-fetch unnecessarily — unless you explicitly run hams refresh --force or install x@latest again to pull a newer version.

Unlike Homebrew or apt, tools installed via go install don’t get an automatic upgrade path. To update, re-run hams goinstall install x@latest — hams will compare recorded versions and reinstall if there’s genuinely something new.

Last updated on