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.12
toolchain go1.23.12

Related terms

Taught in

References