Read compatibility policy and release history
Read compatibility policy and release history
The Go 1 compatibility promise protects correctly written programs using the documented language and public standard-library APIs, with stated exceptions including security fixes, bugs, unspecified behavior and unsafe use. It does not promise identical performance, internal ABI or binaries. Read the official compatibility document, release notes and release history for every upgrade. Go 1.18 introduced generics; Go 1.22 changed loop-variable semantics for modules declaring that language version. These are historical examples, not claims about the newest release.
package main
import ( "fmt" "go/version")
func main() { fmt.Println(version.Compare("go1.9", "go1.10") < 0) fmt.Println(version.Compare("go1.23rc1", "go1.23.0") < 0) fmt.Println(version.IsValid("1.23"))}Lexical string comparison misorders 1.9 and 1.10. The standard go/version package (introduced in Go 1.22) compares Go toolchain versions, not arbitrary module semantic versions. Its order also distinguishes release candidates from final releases. A newer compiler can still apply older module language semantics. To test a migration, compare identical sources under controlled module directives and toolchain versions.
Expected output:
truetruefalseObserve language-version-sensitive behavior
package main
import ( "fmt")
func main() { var fs []func() int for _, v := range []int{1, 2, 3} { fs = append(fs, func() int { return v }) } for _, f := range fs { fmt.Println(f()) }}This source is run as a standalone file using Go 1.23.2 and new loop semantics. In a module with go 1.21, the same source can print 3 three times because the variable is shared across iterations; with go 1.22 it prints 1, 2, 3. The included migration lab actually tests both directives with the same compiler. Do not equate this with testing two installed compiler releases. Treat security fixes as reasons to upgrade, not reasons to pin unsafe behavior forever.
Expected output:
123Try it locally
Make the closure example work under both old and new loop semantics by explicitly creating an iteration-local copy. Verify the three results.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Toolchain and compatibility 05: Read compatibility policy and release history
Check the lesson objective before moving on.
Which is outside the compatibility promise?
What selects the loop-variable semantics in a module?