Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Marshaler ¶
type Marshaler struct { runtime.Marshaler // RowDelim specifies the delimiter between rows RowDelim string // FieldDelim specifies the delimiter between fields FieldDelim string // InnerDelim specifies the delimiter of merged values (slices / maps) within one field. InnerDelim string // used to print types (e.g. int, float, ...) Printf func(format string, a ...any) string // NoHeader suppresses to render the header NoHeader bool }
func (*Marshaler) ContentType ¶
ContentType returns 'text/csv'.
func (*Marshaler) Marshal ¶
Marshal renders the structure in i as CSV.
If i is a slice or a struct that contains slices each slice is rendered to a CSV block. These top-level slices need to contain structs otherwise an error is returned. Each top-level slices is rendered to one block. The blocks are delimited by '---\n'. Empty slices or nil pointers are ignored.
Each csv block consists of a header (if NoHeader option is false) and multiple rows delimited by m.RowDelimi. Each row is a 'flat' representation of the corresponding slice elements:
- struct fields are visible on top-level with own header delimited by m.FieldDelim
- nested slices / maps are flatened delimited by m.InnerDelim
Click to show internal directories.
Click to hide internal directories.