inancgumus/learngo · error
wrong input: %q (line #%d)
Error message
wrong input: %q (line #%d)
What it means
parse() rejects the second field of a log line when strconv.Atoi fails or the parsed visits count is negative. It fires on non-numeric visit counts (e.g. "abc") or negative counts; %q quotes the offending token and p.lines identifies the line in the log file.
Source
Thrown at 25-functions/03-refactor-to-funcs/parser.go:49
parsed.domain = fields[0]
parsed.visits, err = strconv.Atoi(fields[1])
if parsed.visits < 0 || err != nil {
err = fmt.Errorf("wrong input: %q (line #%d)", fields[1], p.lines)
return
}View on GitHub (pinned to 3c475a78e5)
Solutions
- Validate the visits token is a non-negative integer before parsing the line.
- Skip the bad line and continue with the remaining log lines.
- Correct the log data so the second column is a valid non-negative number.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at 25-functions/03-refactor-to-funcs/parser.go:49 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/66a95447f1729c93.
Report an issue: GitHub.