Standard library / encoding/csv
encoding/csv.ParseError
Structured CSV error containing StartLine, Line, one-based byte Column and underlying Err. Use errors.As to obtain location and errors.Is to classify cause. Expected stdout: 'true 2 2 true\n'.
Formal Syntax & Structure
go syntaxgo
type ParseError struct { StartLine int Line int Column int Err error}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), p.StartLine, p.Line, errors.Is(e, csv.ErrFieldCount))}