{"record":{"id":"b8622b557738f520","repo":"golang/go","slug":"can-t-request-explicit-version-of-tool-pattern","errorCode":null,"errorMessage":"can't request explicit version of \"tool\" pattern","messagePattern":"can't request explicit version of \"tool\" pattern","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modget/query.go","lineNumber":207,"sourceCode":"\t\t// If there is no main module, \"all\" is not meaningful.\n\t\tif !ld.HasModRoot() {\n\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)","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modget/query.go#L189-L225","documentation":"Returned by query.validate when the pattern resolves to the 'tool' meta-package (the set of Go toolchain binaries) AND the user supplied an explicit @version suffix. Meta-packages are resolved by the local toolchain and cannot be pinned to a module version. Triggered only when q.pattern != q.raw (i.e. raw input was something like 'tool@x' that collapsed to 'tool').","triggerScenarios":"Running `go get tool@1.21.0`, `go get tool@latest`, or any query whose raw form has a version suffix but whose normalized pattern equals 'tool'. Reached from query.validate when search.IsMetaPackage(pattern) is true, pattern != 'all', pattern != raw, and pattern == \"tool\".","commonSituations":"Trying to upgrade the Go toolchain via `go get tool@version` instead of the supported `go get toolchain@version`; confusing the 'tool' wildcard meta-package with the 'toolchain' module.","solutions":["Drop the version: `go get tool` is accepted but does not upgrade anything.","To change the Go toolchain, use `go get toolchain@<version>` (or `go get go@<version>`) instead of `go get tool@<version>`.","Install a specific tool binary via `go install golang.org/x/tools/<cmd>@<version>` rather than the 'tool' meta-package."],"exampleFix":"// before\n$ go get tool@1.21.0\n// after\n$ go get toolchain@1.21.0","handlingStrategy":"validation","validationCode":"// Reject explicit versions on meta-packages before calling go get.\nvar metaPackages = map[string]bool{\"all\": true, \"std\": true, \"cmd\": true, \"tool\": true}\n\nfunc validateGetArg(arg string) error {\n    pkg, ver, _ := strings.Cut(arg, \"@\")\n    if ver != \"\" && metaPackages[pkg] {\n        if pkg == \"tool\" {\n            return fmt.Errorf(\"cannot version the %q meta-package; use `go get toolchain@%s`\", pkg, ver)\n        }\n        return fmt.Errorf(\"cannot version the %q standard-library meta-package\", pkg)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Distinguish 'tool' (meta-package) from 'toolchain' (versionable module).","Lint scripts for any `go get <meta>@<version>` pattern.","Pin the toolchain via `go get go@<version>` or `go get toolchain@<version>`."],"tags":["go-modules","go-get","toolchain"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}