go
The Go toolchain: an exact upstream release, or the distribution package.
Installs the Go compiler and gofmt.
devtools:
- name: goVersion behavior
version | Debian / Ubuntu | Alpine |
|---|---|---|
| omitted | the distribution’s golang-go package | the distribution’s go package |
| set | the official upstream tarball for that exact release, unpacked into /usr/local/go | the distribution package (the official tarball is glibc-only) |
A pinned version must be an exact upstream release number: 1.22.5, not 1.22 and
not latest. The tarball is fetched for the workstation’s architecture and go and
gofmt are symlinked onto /usr/local/bin, so they are on every login shell’s PATH.
Updates
Without a version, and on Alpine, Go comes from the distribution’s packages, so it moves
with the operating system updates the workstation applies. An upstream release you
pinned with version stays on it. When Go moves, the workstation reinstalls your go
packages at the versions they already have.
Automatic installation
A configuration that declares go packages
needs Go. When the workstation has no go and no config declares the go devtool,
Ringleader adds it. On Debian and Ubuntu the added devtool carries a version, so the
workstation gets an upstream release. On Alpine it gets the distribution’s Go, and a newer
Go is fetched when a module needs one.
A workstation that already has Go keeps it, and Ringleader adds nothing. If a go
package then fails to build because that Go is too old, the setup message names the Go
version the package needs and the version the workstation has. It says to declare the go
devtool with a version. On Debian and Ubuntu, a declared devtool with a version
replaces the Go that is there.
Example
A config that pins the toolchain for a Go service and its linter:
apiVersion: workstations.ringleader.dev/v1
kind: WorkstationConfig
metadata:
name: go-dev
namespace: local
spec:
selector:
matchLabels:
stack: go
packages:
- git
devtools:
- name: go
version: "1.22.5"
- name: golangci-lint # picks up the toolchain installed aboveDeclaring go before golangci-lint matters: golangci-lint is installed with
the Go toolchain, and devtools install in declared order, so the pinned toolchain is
the one that builds it.
Notes
- Re-pinning the version reinstalls Go on the next setup run;
/usr/local/gois replaced, not merged. - The workstation is considered to have this devtool once
goresolves on PATH. - On Alpine the
versionfield is accepted but has no effect; the workstation always gets the distribution package.