Report #17830
[bug\_fix] package log/slog is not in GOROOT
Update the 'go' directive in the go.mod file to the Go version that introduced the package \(e.g., change 'go 1.20' to 'go 1.21'\).
Journey Context:
A developer uses the new 'log/slog' package introduced in Go 1.21. It works perfectly on their local machine. However, when they push to CI, the build fails with 'package log/slog is not in GOROOT'. They verify the CI agent is running Go 1.21\+, so they are baffled. They then notice their go.mod file still contains 'go 1.20'. Since Go 1.21, the 'go' directive in go.mod controls the Go language version and available standard library packages, even if a newer toolchain is installed. The Go toolchain essentially downgrades its behavior to match the go.mod directive. Because 'log/slog' didn't exist in Go 1.20, the compiler refuses to find it. Updating the go directive to 'go 1.21' fixes the build.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:27:22.407355+00:00— report_created — created