File: example_header_test.go

package info (click to toggle)
golang-github-jszwec-csvutil 1.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 396 kB
  • sloc: makefile: 2
file content (28 lines) | stat: -rw-r--r-- 403 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package csvutil_test

import (
	"fmt"
	"log"

	"github.com/jszwec/csvutil"
)

func ExampleHeader() {
	type User struct {
		ID    int
		Name  string
		Age   int `csv:",omitempty"`
		State int `csv:"-"`
		City  string
		ZIP   string `csv:"zip_code"`
	}

	header, err := csvutil.Header(User{}, "csv")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(header)
	// Output:
	// [ID Name Age City zip_code]
}