inancgumus/learngo · error
wrong input: %v (line #%d)
Error message
wrong input: %v (line #%d)
What it means
Same validation as the earlier exercise: parse() rejects a log line whose whitespace-separated field count is not exactly two (domain plus visits). The message includes the offending fields slice and the parser's line counter so the bad line can be located in the input file.
Source
Thrown at 25-functions/04-pass-by-value-semantics/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
}View on GitHub (pinned to 3c475a78e5)
Solutions
- Skip malformed lines and continue parsing the remaining input.
- Fix the log line to contain exactly a domain and a visits value.
- Abort and report the offending line number to the user.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at 25-functions/04-pass-by-value-semantics/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/49a8db5cfc6e2254.
Report an issue: GitHub.