{"record":{"id":"a657ca43fa6f2f53","repo":"golangci/golangci-lint","slug":"v-w","errorCode":null,"errorMessage":"%v: %w","messagePattern":"%v: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/lint/package.go","lineNumber":127,"sourceCode":"func (*PackageLoader) parseLoadedPackagesErrors(pkgs []*packages.Package) error {\n\tfor _, pkg := range pkgs {\n\t\tvar errs []packages.Error\n\t\tfor _, err := range pkg.Errors {\n\t\t\t// quick fix: skip error related to `go list` invocation by packages.Load()\n\t\t\t// The behavior has been changed between go1.19 and go1.20, the error is now inside the JSON content.\n\t\t\t// https://github.com/golangci/golangci-lint/pull/3414#issuecomment-1364756303\n\t\t\tif strings.Contains(err.Msg, \"# command-line-arguments\") {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\terrs = append(errs, err)\n\n\t\t\tif strings.Contains(err.Msg, \"no Go files\") {\n\t\t\t\treturn fmt.Errorf(\"package %s: %w\", pkg.PkgPath, exitcodes.ErrNoGoFiles)\n\t\t\t}\n\t\t\tif strings.Contains(err.Msg, \"cannot find package\") {\n\t\t\t\t// when analyzing not existing directory\n\t\t\t\treturn fmt.Errorf(\"%v: %w\", err.Msg, exitcodes.ErrFailure)\n\t\t\t}\n\t\t}\n\n\t\tpkg.Errors = errs\n\t}\n\n\treturn nil\n}\n\nfunc (l *PackageLoader) tryParseTestPackage(pkg *packages.Package) (name string, isTest bool) {\n\tmatches := l.pkgTestIDRe.FindStringSubmatch(pkg.ID)\n\tif matches == nil {\n\t\treturn \"\", false\n\t}\n\n\treturn matches[1], true\n}\n","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/lint/package.go#L109-L145","documentation":"In parseLoadedPackagesErrors, when a package error contains \"cannot find package\", golangci-lint wraps it as \"<msg>: failure\" (exitcodes.ErrFailure). Per the source comment this happens when analyzing a directory that does not exist — the Go toolchain cannot resolve the given package path.","triggerScenarios":"Passing a package pattern whose directory does not exist (e.g. `golangci-lint run ./nonexistent/...`), or an import inside the code pointing to a package that cannot be found because a dependency/module is missing.","commonSituations":"Typo in the path given on the command line; CI scripts referencing a directory that was moved/renamed; missing `go mod download` / vendoring so imports cannot resolve.","solutions":["Verify the path passed to golangci-lint exists relative to the module root (check for typos)","Run `go mod download` (or use vendoring consistently) so all imports resolve","Run `go build ./...` to see the full \"cannot find package\" message and fix the missing module/import","Fix CI scripts or Makefiles that reference renamed/moved directories"],"exampleFix":"// before (shell)\ngolangci-lint run ./internal/lint/...\n// after  (dir was renamed)\ngolangci-lint run ./pkg/lint/...","handlingStrategy":"validation","validationCode":"// Verify target paths exist before invoking golangci-lint:\n// for p in \"$@\"; do\n//   [ -e \"$p\" ] || { echo \"path does not exist: $p\"; exit 1; }\n// done","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use relative patterns from the module root and keep them in the Makefile/CI near the repo layout","Run `go mod download` (or commit vendor/) so all imports resolve","Grep CI scripts for hardcoded paths after directory renames","Prefer `./...` over enumerating directories manually when possible"],"tags":["golangci-lint","go-packages","missing-path"],"backgroundTag":"package-not-found","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}