inancgumus/learngo · error
wrong input: %q (line #%d)
Error message
wrong input: %q (line #%d)
What it means
Pointer-based parse(): fires when the visits token cannot be converted by strconv.Atoi or is negative. The error is stored in p.lerr, which stops all subsequent parsing and aggregation; the quoted token and line number identify the exact bad input.
Source
Thrown at 26-pointers/05-log-parser-pointers-vs-values/parser.go:58
r.domain = fields[0]
r.visits, err = strconv.Atoi(fields[1])
if r.visits < 0 || err != nil {
p.lerr = fmt.Errorf("wrong input: %q (line #%d)", fields[1], p.lines)
}
returnView on GitHub (pinned to 3c475a78e5)
Solutions
- After parsing, check p.lerr in main and report the invalid line.
- Skip lines whose visits column is not a non-negative integer.
- Correct the log data at the reported line.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at 26-pointers/05-log-parser-pointers-vs-values/parser.go:58 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of inancgumus/learngo@3c475a78e5 (2026-09-02).
Data as JSON: /api/errors/5aa5cbc767e2c14e.
Report an issue: GitHub.