inancgumus/learngo · error
wrong input: %v (line #%d)
Error message
wrong input: %v (line #%d)
What it means
Exercise variant of parse(): rejects a log line that does not contain exactly two whitespace-separated fields. The error carries the offending fields slice and p.lines so main can report which line of the log is malformed.
Source
Thrown at 26-pointers/exercises/05-log-parser/parser.go:41
// parse parses a log line and returns the parsed result with an error
func parse(p parser, line string) (parsed result, err error) {
fields := strings.Fields(line)
if len(fields) != 2 {
err = fmt.Errorf("wrong input: %v (line #%d)", fields, p.lines)
return
}
parsed.domain = fields[0]View on GitHub (pinned to 3c475a78e5)
Solutions
- Skip malformed lines and continue with the rest of the file.
- Fix the log line to have exactly domain and visits columns.
- Stop and surface the line number to the user.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at 26-pointers/exercises/05-log-parser/parser.go:41 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/1efffcce060ddf63.
Report an issue: GitHub.