Standard library / encoding/csv

encoding/csv.ErrTrailingComma

Deprecated sentinel kept for compatibility; modern CSV readers no longer return it for trailing commas. A trailing comma denotes an empty final field. Expected stdout: '2 true true\n'.

Formal Syntax & Structure

go syntaxgo
var ErrTrailingComma error

Working Example

Example Snippetgo
package main
import (  "encoding/csv"  "fmt"  "strings")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  r := csv.NewReader(strings.NewReader("a,\n"))  x, e := r.Read()  must(e)  fmt.Println(len(x), x[1] == "", csv.ErrTrailingComma != nil)}
Go Reference