golang/go · error
can't request explicit version of standard-library pattern %
Error message
can't request explicit version of standard-library pattern %q
What it means
Returned by query.validate when the pattern is a standard-library meta-package other than 'all'/'tool' (e.g. 'std', 'cmd') AND an explicit @version was supplied. Standard-library packages ship with the toolchain and cannot be fetched at a chosen module version. The %q slot is the offending pattern name.
Source
Thrown at src/cmd/go/internal/modget/query.go:209
return fmt.Errorf(`cannot match "all": %v`, modload.NewNoMainModulesError(ld))
}
if !versionOkForMainModule(q.version) {
// TODO(bcmills): "all@none" seems like a totally reasonable way to
// request that we remove all module requirements, leaving only the main
// module and standard library. Perhaps we should implement that someday.
return &modload.QueryUpgradesAllError{
MainModules: ld.MainModules.Versions(),
Query: q.version,
}
}
}
if search.IsMetaPackage(q.pattern) && q.pattern != "all" {
if q.pattern != q.raw {
if q.pattern == "tool" {
return fmt.Errorf("can't request explicit version of \"tool\" pattern")
}
return fmt.Errorf("can't request explicit version of standard-library pattern %q", q.pattern)
}
}
return nil
}
// String returns the original argument from which q was parsed.
func (q *query) String() string { return q.raw }
// ResolvedString returns a string describing m as a resolved match for q.
func (q *query) ResolvedString(m module.Version) string {
if m.Path != q.pattern {
if m.Version != q.version {
return fmt.Sprintf("%v (matching %s@%s)", m, q.pattern, q.version)
}
return fmt.Sprintf("%v (matching %v)", m, q)
}
if m.Version != q.version {View on GitHub (pinned to b6b368adc5)
Solutions
- Remove the @version suffix when fetching standard-library meta-packages.
- To change which standard library you compile against, switch the active Go toolchain (e.g. `go get go@1.20`) instead of pinning 'std'.
- If you need a specific std package at a specific version, vendor it into your module under a separate import path.
Example fix
// before $ go get std@1.20 // after $ go get go@1.20 # switches the toolchain (and thus std)
Defensive patterns
Strategy: validation
Validate before calling
// Mirror of modget.query.validate for std meta-packages.
func rejectStdVersion(arg string) error {
pkg, ver, _ := strings.Cut(arg, "@")
std := map[string]bool{"std": true, "cmd": true}
if ver != "" && std[pkg] {
return fmt.Errorf("cannot pin standard-library meta-package %q; switch toolchain instead", pkg)
}
return nil
} Prevention
- Treat 'std' and 'cmd' as fixed by the active Go toolchain, not by module versions.
- Drive toolchain selection through the `go` directive in go.mod.
- Audit CI scripts for any '@' suffix on standard-library meta-packages.
When it happens
Trigger: Running `go get std@1.20`, `go get cmd@latest`, or any query whose raw form carries a version but whose normalized pattern is a standard-library meta-package. Reached from query.validate in the else-branch after the 'tool' check.
Common situations: Mistakenly treating 'std' or 'cmd' as importable modules; attempting to downgrade the standard library to match an older Go release.
Related errors
- %s%s is not within module%s rooted at %s
- no package to get in current directory
- %s%s is not a package in module rooted at %s
- %v matches packages in %v but not %v: specify a different ve
- invalid module version syntax %q
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/653574b2b3b169a4.
Report an issue: GitHub.