{"record":{"id":"653574b2b3b169a4","repo":"golang/go","slug":"can-t-request-explicit-version-of-standard-library","errorCode":null,"errorMessage":"can't request explicit version of standard-library pattern %q","messagePattern":"can't request explicit version of standard-library pattern %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modget/query.go","lineNumber":209,"sourceCode":"\t\t\treturn fmt.Errorf(`cannot match \"all\": %v`, modload.NewNoMainModulesError(ld))\n\t\t}\n\t\tif !versionOkForMainModule(q.version) {\n\t\t\t// TODO(bcmills): \"all@none\" seems like a totally reasonable way to\n\t\t\t// request that we remove all module requirements, leaving only the main\n\t\t\t// module and standard library. Perhaps we should implement that someday.\n\t\t\treturn &modload.QueryUpgradesAllError{\n\t\t\t\tMainModules: ld.MainModules.Versions(),\n\t\t\t\tQuery:       q.version,\n\t\t\t}\n\t\t}\n\t}\n\n\tif search.IsMetaPackage(q.pattern) && q.pattern != \"all\" {\n\t\tif q.pattern != q.raw {\n\t\t\tif q.pattern == \"tool\" {\n\t\t\t\treturn fmt.Errorf(\"can't request explicit version of \\\"tool\\\" pattern\")\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"can't request explicit version of standard-library pattern %q\", q.pattern)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// String returns the original argument from which q was parsed.\nfunc (q *query) String() string { return q.raw }\n\n// ResolvedString returns a string describing m as a resolved match for q.\nfunc (q *query) ResolvedString(m module.Version) string {\n\tif m.Path != q.pattern {\n\t\tif m.Version != q.version {\n\t\t\treturn fmt.Sprintf(\"%v (matching %s@%s)\", m, q.pattern, q.version)\n\t\t}\n\t\treturn fmt.Sprintf(\"%v (matching %v)\", m, q)\n\t}\n\tif m.Version != q.version {","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modget/query.go#L191-L227","documentation":"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.","triggerScenarios":"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.","commonSituations":"Mistakenly treating 'std' or 'cmd' as importable modules; attempting to downgrade the standard library to match an older Go release.","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."],"exampleFix":"// before\n$ go get std@1.20\n// after\n$ go get go@1.20   # switches the toolchain (and thus std)","handlingStrategy":"validation","validationCode":"// Mirror of modget.query.validate for std meta-packages.\nfunc rejectStdVersion(arg string) error {\n    pkg, ver, _ := strings.Cut(arg, \"@\")\n    std := map[string]bool{\"std\": true, \"cmd\": true}\n    if ver != \"\" && std[pkg] {\n        return fmt.Errorf(\"cannot pin standard-library meta-package %q; switch toolchain instead\", pkg)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["go-modules","go-get","standard-library"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}