Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func (*Reader) Err ¶
Return the last error encountered; returns nil if no error was encountered or if the last error was io.EOF.
func (*Reader) Fields ¶
Returns the last row of fields encountered. These fields are only valid until the next call to Next() or Read().
func (*Reader) Next ¶
Scans in the next row
Example ¶
r := NewReader(strings.NewReader(`Language,Sponsor
golang,Google
swift,Apple
rust,Mozilla`))
for r.Next() {
fmt.Printf("[%s]\n", string(bytes.Join(r.Fields(), []byte(" | "))))
}
if err := r.Err(); err != nil {
panic(err)
}
Output: [Language | Sponsor] [golang | Google] [swift | Apple] [rust | Mozilla]
func (*Reader) Read ¶
Read and return the next row and/or any errors encountered. The byte slices are only valid until the next call to Next() or Read(). Returns nil, io.EOF when the file is consumed.
Example ¶
r := NewReader(strings.NewReader(`Language,Sponsor
golang,Google
swift,Apple
rust,Mozilla`))
for {
row, err := r.Read()
if err != nil {
if err == io.EOF {
break
}
panic(err)
}
fmt.Printf("[%s]\n", string(bytes.Join(row, []byte(" | "))))
}
Output: [Language | Sponsor] [golang | Google] [swift | Apple] [rust | Mozilla]
Click to show internal directories.
Click to hide internal directories.
