Golang encoding/csv.Writer.WriteAll() function example
package encoding/csv
WriteAll writes multiple CSV records to w(given input type) using Write and then calls Flush.
Golang encoding/csv.Writer.WriteAll() function usage example
package main
import (
"encoding/csv"
"fmt"
"os"
)
func main() {
csvfile, err := os.Create("output.csv")
if err != nil {
fmt.Println("Error:", err)
return
}
defer csvfile.Close()
records := [][]string{{"item1", "value1"}, {"item2", "value2"}, {"item3", "value3"}}
writer := csv.NewWriter(csvfile)
err = writer.WriteAll(records) // flush everything into csvfile
if err != nil {
fmt.Println("Error:", err)
return
}
}
Reference :
See also : Golang encoding/csv.Writer.Write() function example
Advertisement
Something interesting
Tutorials
+12.8k Golang : Listen and Serve on sub domain example
+9.3k Golang : How to get ECDSA curve and parameters data?
+20.7k Android Studio : AlertDialog and EditText to get user string input example
+9.7k Golang : Eroding and dilating image with OpenCV example
+11.4k Golang : Concatenate (combine) buffer data example
+9k Golang : Populate or initialize struct with values example
+8.1k Golang : Tell color name with OpenCV example
+6.9k Mac/Linux/Windows : Get CPU information from command line
+7.9k Golang : Ways to recover memory during run time.
+24.1k Golang : Upload to S3 with official aws-sdk-go package
+10.2k Golang : Check a web page existence with HEAD request example
+6.3k Javascript : Generate random key with specific length