Standard library / encoding/csv
encoding/csv.ParseError.Error()
Describe a CSV parsing error with record and error locations. Inspect StartLine, Line, Column and Err for structured diagnostics. Expected stdout: 'true true\n'.
Formal Syntax & Structure
go syntaxgo
func (e *ParseError) Error() stringReturn Value
string
Text representation or diagnostic.
Working Example
Example Snippetgo
package main
import ( "encoding/csv" "errors" "fmt" "strings")
func must(e error) { if e != nil { panic(e) }}
func main() { r := csv.NewReader(strings.NewReader("a,b\nc\n")) _, e := r.Read() must(e) _, e = r.Read() var p *csv.ParseError fmt.Println(errors.As(e, &p), len(p.Error()) > 0)}