{"record":{"id":"00bc3af852954b4f","repo":"golangci/golangci-lint","slug":"can-t-parse-line-number-q-w","errorCode":null,"errorMessage":"can't parse line number %q: %w","messagePattern":"can't parse line number %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/goanalysis/pkgerrors/parse.go","lineNumber":38,"sourceCode":"\n\treturn &result.Issue{\n\t\tPos:        *pos,\n\t\tText:       srcErr.Msg,\n\t\tFromLinter: \"typecheck\",\n\t}, nil\n}\n\nfunc parseErrorPosition(pos string) (*token.Position, error) {\n\t// file:line(<optional>:column)\n\tparts := strings.Split(pos, \":\")\n\tif len(parts) == 1 {\n\t\treturn nil, errors.New(\"no colons\")\n\t}\n\n\tfile := parts[0]\n\tline, err := strconv.Atoi(parts[1])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't parse line number %q: %w\", parts[1], err)\n\t}\n\n\tvar column int\n\tif len(parts) == 3 { // got column\n\t\tcolumn, err = strconv.Atoi(parts[2])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse column from %q: %w\", parts[2], err)\n\t\t}\n\t}\n\n\treturn &token.Position{\n\t\tFilename: file,\n\t\tLine:     line,\n\t\tColumn:   column,\n\t}, nil\n}\n","sourceCodeStart":20,"sourceCodeEnd":55,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/goanalysis/pkgerrors/parse.go#L20-L55","documentation":"When golangci-lint parses compiler error output to attach positions to issues (pkgerrors), parseErrorPosition splits a 'file:line:col' string and converts the line field with strconv.Atoi. If the line segment isn't an integer it wraps the Atoi error with the offending value via %w.","triggerScenarios":"extractErrors/parseError feed a string whose second colon-separated field is not numeric, e.g. output like 'file.go:xyz:5: message' or a position line with extra/missing segments so parts[1] is not a number.","commonSituations":"Non-Go tool output mixed into error streams; compiler messages in an unexpected locale/format; malformed lines from cgo or custom analyzers that don't follow the file:line:col convention.","solutions":["Check the raw error string being parsed; identify the line that does not match file:line[:col] format","Fix or filter the producer of malformed output so it emits standard go/compiler positions","Upgrade golangci-lint / the analyzer emitting non-standard output","If parsing your own output, verify with regexp `^(.+):(\\d+)(?::(\\d+))?:` before calling the parser"],"exampleFix":"// before - malformed line fed to parser\n\"foo.go:1a: error text\"\n// after - standard position format\n\"foo.go:1:10: error text\"","handlingStrategy":"validation","validationCode":"var posRe = regexp.MustCompile(`^[^:]+:\\d+:\\d+:`)\n// ensure third field is numeric before parsing","typeGuard":null,"tryCatchPattern":"if pos, err := parseErrorPosition(s); err != nil {\n    log.Printf(\"dropping malformed diagnostic %q: %v\", s, err)\n}","preventionTips":["Standardize diagnostic format to file:line:col across tools","Pre-validate column field with strconv/regex","Avoid concatenating free-form log text into position strings"],"tags":["golangci-lint","parsing","go","strconv"],"backgroundTag":"line-number-parse-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}