golangci/golangci-lint · warning

failed to parse column from %q: %w

Error message

failed to parse column from %q: %w

What it means

parseErrorPosition expects at most three colon-separated fields (file:line:column). When a third field exists but is not a valid integer, strconv.Atoi fails and the parser wraps the error with the offending column string via %w.

Source

Thrown at pkg/goanalysis/pkgerrors/parse.go:45

func parseErrorPosition(pos string) (*token.Position, error) {
	// file:line(<optional>:column)
	parts := strings.Split(pos, ":")
	if len(parts) == 1 {
		return nil, errors.New("no colons")
	}

	file := parts[0]
	line, err := strconv.Atoi(parts[1])
	if err != nil {
		return nil, fmt.Errorf("can't parse line number %q: %w", parts[1], err)
	}

	var column int
	if len(parts) == 3 { // got column
		column, err = strconv.Atoi(parts[2])
		if err != nil {
			return nil, fmt.Errorf("failed to parse column from %q: %w", parts[2], err)
		}
	}

	return &token.Position{
		Filename: file,
		Line:     line,
		Column:   column,
	}, nil
}

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Inspect the exact string in the error; find the producer emitting 'file:line:<non-numeric>' positions
  2. Normalize/filter the output so columns are numeric (or drop the column segment)
  3. Upgrade or patch the tool producing malformed diagnostics
  4. Pre-validate with regexp before parsing

Example fix

// before
"foo.go:12:x: something"
// after
"foo.go:12:3: something"
Defensive patterns

Strategy: validation

Validate before calling

// ensure exactly file:line:col with numeric col
var posRe = regexp.MustCompile(`^[^:]+:\d+:\d+(:\s|$)`)
func hasValidColumn(line string) bool { return posRe.MatchString(line) }

Try / catch

pos, err := parseErrorPosition(s)
if err != nil {
    log.Printf("skipping line with bad column: %v", err)
    return nil
}

Prevention

When it happens

Trigger: A diagnostic line like 'file.go:12:abc: message' reaches parseError/extractErrors; parts has 3 elements and parts[2] is non-numeric.

Common situations: Analyzer or compiler output that appends extra text after the column without a fourth colon-separated message part; custom linters printing positions in a slightly different format; pasted/concatenated log lines.

Understand the failure class

Related errors


AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02). Data as JSON: /api/errors/37196c884f1daef4. Report an issue: GitHub.