how to create csv file in golang
package main
import (
"encoding/csv"
"log"
"os"
)
func main() {
empData := [][]string{
{"Name", "City"},
{"Smith", "India"},
}
csvFile, err := os.Create("fileName.csv")
if err != nil {
log.Fatalf("failed creating file: %s", err)
}
csvwriter := csv.NewWriter(csvFile)
for _, empRow := range empData {
_ = csvwriter.Write(empRow)
}
csvwriter.Flush()
csvFile.Close()
}