Standard library / encoding/csv
encoding/csv.Reader
CSV parser. Configure Comma, Comment, FieldsPerRecord, LazyQuotes, TrimLeadingSpace and ReuseRecord before reading. TrailingComma is deprecated and ignored. ReuseRecord allows later reads to reuse the slice backing array. Expected stdout: '[a b]\n'.
Formal Syntax & Structure
go syntaxgo
type Reader struct { Comma rune
Comment rune
FieldsPerRecord int
LazyQuotes bool
TrimLeadingSpace bool
ReuseRecord bool
TrailingComma bool
// Has unexported fields.}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;b\n")) r.Comma = ';' x, e := r.Read() must(e) fmt.Println(x)}