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 field fails strconv.Atoi or is negative; the error is saved into p.lerr (no return value), which halts all further parsing and updating. The quoted token and line number let the user find the bad row in the log file.
Source
Thrown at 26-pointers/04-log-parser-pointers/parser.go:58
var err error
parsed.visits, err = strconv.Atoi(fields[1])
if parsed.visits < 0 || err != nil {
p.lerr = fmt.Errorf("wrong input: %q (line #%d)", fields[1], p.lines)
}
returnView on GitHub (pinned to 3c475a78e5)
Solutions
- Check p.lerr in main and stop with a clear message about the invalid line.
- Filter out lines with non-numeric or negative visit counts before parsing.
- Correct the source log so the visits column is a valid non-negative integer.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at 26-pointers/04-log-parser-pointers/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/f27796b5e25f34b5.
Report an issue: GitHub.