{"record":{"id":"fd54da9c7f42ee16","repo":"golang/go","slug":"s-s-is-not-a-package-in-module-rooted-at-s","errorCode":null,"errorMessage":"%s%s is not a package in module rooted at %s","messagePattern":"(.+?)(.+?) is not a package in module rooted at (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modget/get.go","lineNumber":817,"sourceCode":"\t\t\t\tvar plural string\n\t\t\t\tif len(modRoots) != 1 {\n\t\t\t\t\tplural = \"s\"\n\t\t\t\t}\n\t\t\t\treturn errSet(fmt.Errorf(\"%s%s is not within module%s rooted at %s\", q.pattern, absDetail, plural, strings.Join(modRoots, \", \")))\n\t\t\t}\n\n\t\t\tmatch := modload.MatchInModule(ld, ctx, pkgPattern, mainModule, imports.AnyTags())\n\t\t\tif len(match.Errs) > 0 {\n\t\t\t\treturn pathSet{err: match.Errs[0]}\n\t\t\t}\n\n\t\t\tif len(match.Pkgs) == 0 {\n\t\t\t\tif q.raw == \"\" || q.raw == \".\" {\n\t\t\t\t\treturn errSet(fmt.Errorf(\"no package to get in current directory\"))\n\t\t\t\t}\n\t\t\t\tif !q.isWildcard() {\n\t\t\t\t\tld.MustHaveModRoot()\n\t\t\t\t\treturn errSet(fmt.Errorf(\"%s%s is not a package in module rooted at %s\", q.pattern, absDetail, ld.MainModules.ModRoot(mainModule)))\n\t\t\t\t}\n\t\t\t\tsearch.WarnUnmatched([]*search.Match{match})\n\t\t\t\treturn pathSet{}\n\t\t\t}\n\n\t\t\treturn pathSet{pkgMods: []module.Version{mainModule}}\n\t\t})\n\t}\n}\n\n// performWildcardQueries populates the candidates for each query whose pattern\n// is a wildcard.\n//\n// The candidates for a given module path matching (or containing a package\n// matching) a wildcard query depend only on the initial build list, but the set\n// of modules may be expanded by other queries, so wildcard queries need to be\n// re-evaluated whenever a potentially-matching module path is added to the\n// build list.","sourceCodeStart":799,"sourceCodeEnd":835,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modget/get.go#L799-L835","documentation":"This error occurs when a non-wildcard local path query resolves inside a module but matches no Go packages. Unlike the '.' case (error 1033), this fires for explicit local paths like './subdir' or '../pkg' that aren't wildcards. The match lookup returns zero packages and the pattern is not '.', so the code reports that the specific path doesn't correspond to a package in the module.","triggerScenarios":"Running 'go get ./nonexistent' or 'go get ./subdir' where subdir has no .go files or doesn't exist within the module. A specific relative path that resolves to a directory without Go packages.","commonSituations":"A developer types a relative subdirectory path that doesn't contain any Go files. A path to a directory that was renamed or deleted. A typo in the relative path. A directory containing only test files (_test.go) when using build tags that exclude them.","solutions":["Verify the directory exists and contains Go files: 'ls ./subdir/*.go'.","Use a wildcard to find available packages: 'go list ./...' to see what packages exist in the module.","Check for typos in the path. Try 'go get ./subdir/...' if you want a wildcard match.","Ensure build tags or build constraints aren't excluding all .go files in the target directory."],"exampleFix":"# before\n$ go get ./cmd/nonexistent\n# ./cmd/nonexistent is not a package in module rooted at /home/user/myproject\n\n# after: find the correct package\n$ go list ./...\n# example.com/myproject/cmd/server\n# example.com/myproject/cmd/cli\n$ go get ./cmd/server","handlingStrategy":"validation","validationCode":"// Verify a local path resolves to a directory with Go files\nfunc validateLocalPackagePath(pattern string) error {\n    absPath, err := filepath.Abs(pattern)\n    if err != nil { return err }\n    info, err := os.Stat(absPath)\n    if err != nil { return fmt.Errorf(\"path %s does not exist: %w\", pattern, err) }\n    if !info.IsDir() { return fmt.Errorf(\"%s is not a directory\", pattern) }\n    matches, _ := filepath.Glob(filepath.Join(absPath, \"*.go\"))\n    if len(matches) == 0 {\n        return fmt.Errorf(\"no .go files in %s\", absPath)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(stderr, \"is not a package in module\") {\n    // Path resolves to a dir with no Go files\n    // Suggest: go list ./... to find valid packages\n}","preventionTips":["Verify paths exist and contain .go files before using them in go get","Use 'go list ./...' to discover available packages in the module","Check for typos in relative paths","Be aware of build tags that might exclude .go files"],"tags":["go-get","go-modules","local-path","no-packages"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}