Documentation ¶
Index ¶
- Variables
- func CSVToMap(in io.Reader) (map[string]string, error)
- func DefaultCSVReader(in io.Reader) *csv.Reader
- func DefaultCSVWriter(out io.Writer) *csv.Writer
- func LazyCSVReader(in io.Reader) *csv.Reader
- func Marshal(in interface{}, out io.Writer) (err error)
- func MarshalBytes(in interface{}) (out []byte, err error)
- func MarshalCSV(in interface{}, out *csv.Writer) (err error)
- func MarshalCSVWithoutHeaders(in interface{}, out *csv.Writer) (err error)
- func MarshalChan(c <-chan interface{}, out *csv.Writer) error
- func MarshalFile(in interface{}, file *os.File) (err error)
- func MarshalString(in interface{}) (out string, err error)
- func MarshalWithoutHeaders(in interface{}, out io.Writer) (err error)
- func SetCSVReader(csvReader func(io.Reader) *csv.Reader)
- func SetCSVWriter(csvWriter func(io.Writer) *csv.Writer)
- func Unmarshal(in io.Reader, out interface{}) (err error)
- func UnmarshalBytes(in []byte, out interface{}) (err error)
- func UnmarshalBytesToCallback(in []byte, f interface{}) (err error)
- func UnmarshalBytesToChan(in []byte, c interface{}) error
- func UnmarshalCSV(in CSVReader, out interface{}) error
- func UnmarshalFile(in *os.File, out interface{}) (err error)
- func UnmarshalString(in string, out interface{}) (err error)
- func UnmarshalStringToCallback(in string, c interface{}) (err error)
- func UnmarshalStringToChan(in string, c interface{}) error
- func UnmarshalToCallback(in io.Reader, f interface{}) (err error)
- func UnmarshalToChan(in io.Reader, c interface{}) error
- type CSVReader
- type Decoder
- type MissingColumnsError
- type NoMarshalFuncError
- type NoUnmarshalFuncError
- type SimpleDecoder
- type Stringer
- type TypeMarshaller
- type TypeUnmarshaller
Constants ¶
This section is empty.
Variables ¶
var (
ErrEmptyCSV = errors.New("empty csv file given")
)
var FailIfDoubleHeaderNames = false
FailIfDoubleHeaderNames indicates whether it is considered an error when a header name is repeated in the csv header.
var FailIfUnmatchedStructTags = true
FailIfUnmatchedStructTags indicates whether it is considered an error when there is an unmatched struct tag.
var ShouldAlignDuplicateHeadersWithStructFieldOrder = false
ShouldAlignDuplicateHeadersWithStructFieldOrder indicates whether we should align duplicate CSV headers per their alignment in the struct definition.
var TagSeparator = ","
TagSeparator defines seperator string for multiple csv tags in struct fields
Functions ¶
func DefaultCSVReader ¶
DefaultCSVReader is the default CSV reader used to parse CSV (cf. csv.NewReader)
func DefaultCSVWriter ¶
DefaultCSVWriter is the default CSV writer used to format CSV (cf. csv.NewWriter)
func LazyCSVReader ¶
LazyCSVReader returns a lazy CSV reader, with LazyQuotes and TrimLeadingSpace.
func MarshalBytes ¶
MarshalBytes returns the CSV bytes from the interface.
func MarshalCSV ¶
MarshalCSV returns the CSV in writer from the interface.
func MarshalCSVWithoutHeaders ¶
MarshalCSV returns the CSV in writer from the interface.
func MarshalChan ¶
MarshalChan returns the CSV read from the channel.
func MarshalFile ¶
MarshalFile saves the interface as CSV in the file.
func MarshalString ¶
MarshalString returns the CSV string from the interface.
func MarshalWithoutHeaders ¶
Marshal returns the CSV in writer from the interface.
func SetCSVReader ¶
SetCSVReader sets the CSV reader used to parse CSV.
func SetCSVWriter ¶
SetCSVWriter sets the CSV writer used to format CSV.
func UnmarshalBytes ¶
UnmarshalBytes parses the CSV from the bytes in the interface.
func UnmarshalBytesToCallback ¶
UnmarshalBytesToCallback parses the CSV from the bytes and send each value to the given func f. The func must look like func(Struct).
func UnmarshalBytesToChan ¶
UnmarshalBytesToChan parses the CSV from the bytes and send each value in the chan c. The channel must have a concrete type.
func UnmarshalCSV ¶
UnmarshalCSV parses the CSV from the reader in the interface.
func UnmarshalFile ¶
UnmarshalFile parses the CSV from the file in the interface.
func UnmarshalString ¶
UnmarshalString parses the CSV from the string in the interface.
func UnmarshalStringToCallback ¶
UnmarshalStringToCallback parses the CSV from the string and send each value to the given func f. The func must look like func(Struct).
func UnmarshalStringToChan ¶
UnmarshalStringToChan parses the CSV from the string and send each value in the chan c. The channel must have a concrete type.
func UnmarshalToCallback ¶
UnmarshalToCallback parses the CSV from the reader and send each value to the given func f. The func must look like func(Struct).
func UnmarshalToChan ¶
UnmarshalToChan parses the CSV from the reader and send each value in the chan c. The channel must have a concrete type.
Types ¶
type MissingColumnsError ¶
type MissingColumnsError struct {
MissingColumnNames []string
}
func (MissingColumnsError) Error ¶
func (e MissingColumnsError) Error() string
type NoMarshalFuncError ¶
type NoMarshalFuncError struct {
// contains filtered or unexported fields
}
NoMarshalFuncError is the custom error type to be raised in case there is no marshal function defined on type
func (NoMarshalFuncError) Error ¶
func (e NoMarshalFuncError) Error() string
type NoUnmarshalFuncError ¶
type NoUnmarshalFuncError struct {
// contains filtered or unexported fields
}
NoUnmarshalFuncError is the custom error type to be raised in case there is no unmarshal function defined on type
func (NoUnmarshalFuncError) Error ¶
func (e NoUnmarshalFuncError) Error() string
type SimpleDecoder ¶
type SimpleDecoder interface {
// contains filtered or unexported methods
}
SimpleDecoder .
type Stringer ¶
type Stringer interface {
String() string
}
Stringer is implemented by any value that has a String method This converter is used to convert the value to it string representation This converter will be used if your value does not implement TypeMarshaller
type TypeMarshaller ¶
TypeMarshaller is implemented by any value that has a MarshalCSV method This converter is used to convert the value to it string representation
type TypeUnmarshaller ¶
TypeUnmarshaller is implemented by any value that has an UnmarshalCSV method This converter is used to convert a string to your value representation of that string