inancgumus/learngo · error
wrong input: %q (line #%d)
Error message
wrong input: %q (line #%d)
What it means
parse() rejects the visits column when strconv.Atoi cannot convert it or the value is negative. The offending token is quoted with %q and p.lines pinpoints the line in the log; the parser (passed by value in this exercise) returns the error to main, which stops the run.
Source
Thrown at 25-functions/04-pass-by-value-semantics/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
- Pre-validate that the visits field parses as a non-negative integer.
- Skip invalid lines and keep processing the rest of the log.
- Repair the input data so visits are non-negative integers.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at 25-functions/04-pass-by-value-semantics/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/de228f0e33db57a5.
Report an issue: GitHub.