Standard library / encoding/csv
encoding/csv.Writer.Error()
Return an error from a previous write or flush; delayed errors must not be ignored. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (w *Writer) Error() errorReturn Value
error
Stored writer error, or nil if no error has occurred.
Working Example
Example Snippetgo
package main
import ( "encoding/csv" "errors" "fmt")
func must(e error) { if e != nil { panic(e) }}
type failing struct{}
func (failing) Write([]byte) (int, error) { return 0, errors.New("disk full") }func main() { w := csv.NewWriter(failing{}) must(w.Write([]string{"x"})) w.Flush() fmt.Println(w.Error() != nil)}