MCPcopy
hub / github.com/betty200744/ultimate-go / TestCSVWrite

Function TestCSVWrite

build-in-package/encoding/csv_test.go:33–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func TestCSVWrite(t *testing.T) {
34 records := [][]string{
35 {"first_name", "last_name", "username"},
36 {"Rob", "Pike", "rob"},
37 {"Ken", "Thompson", "ken"},
38 {"Robert", "Griesemer", "gri"},
39 }
40 file, err := os.Create("./a.csv")
41 if err != nil {
42 log.Fatal(err)
43 }
44 defer file.Close()
45 w := csv.NewWriter(file)
46 for _, record := range records {
47 if e := w.Write(record); e != nil {
48 log.Fatal(e)
49 }
50 }
51 w.Flush()
52}

Callers

nothing calls this directly

Calls 2

WriteMethod · 0.95
CloseMethod · 0.45

Tested by

no test coverage detected