toolchain directive
Lines in go.mod that state which Go language version a module needs and, optionally, which exact toolchain release should build it.
In more detail
The go line, such as go 1.23.12, is the minimum language version the module requires. An optional toolchain line names a preferred release, and a newer go command can download that toolchain automatically. This pins builds to a known compiler without installing it by hand on every machine.
Examples
go 1.23.12toolchain go1.23.12Related terms
- go.mod — The text file at the root of a Go module that records its module path, the Go version it needs and the other modules it depends on.
- toolchain — A set of programs that work together to get one job done, such as building and running software.
- Go module — A tree of Go packages that is versioned and released together, described by a go.mod file at its root.
Taught in
- Installing the Go Toolchain — Concurrent Systems Programming with Go
- Go Workspaces and Modules — Concurrent Systems Programming with Go