csv2: github.com/aodin/csv2 Index | Files

package csv

import "github.com/aodin/csv2"

Index

Package Files

csv2.go

Variables

var (
    ErrNotPointer = errors.New("csv2: non-pointer receiver")
    ErrNotSlice   = errors.New("csv2: receiver must be a slice of structs")
    ErrNotStruct  = errors.New("csv2: receiver must be a struct")
    ErrUnwritable = errors.New("csv2: writers accept struct or struct slices")
)

func GetFieldNames Uses

func GetFieldNames(i interface{}) ([]string, error)

GetFieldNames returns a string array of the given interface's field names if the given interface is a struct or slice of structs

type Reader Uses

type Reader struct {
    *csv.Reader
    // contains filtered or unexported fields
}

Reader wraps the csv.Reader and adds a map of csv struct tags.

func NewReader Uses

func NewReader(r io.Reader) *Reader

NewReader returns a new csv2 Reader by wrapping a csv Reader.

func (*Reader) Unmarshal Uses

func (r *Reader) Unmarshal(i interface{}) error

Unmarshal reads the entire Reader into the given destination. The destination interface must of pointer of type slice.

func (*Reader) UnmarshalOne Uses

func (r *Reader) UnmarshalOne(i interface{}) error

UnmarshalOne reads a single row of the Reader into the given struct. The destination interface must of pointer of type struct.

type Writer Uses

type Writer struct {
    *csv.Writer
    // contains filtered or unexported fields
}

Writer wraps the csv.Writer and adds a map of csv struct tags.

func NewWriter Uses

func NewWriter(r io.Writer) *Writer

NewWriter returns a new csv2 Writer by wrapping a csv Writer.

func (*Writer) Marshal Uses

func (w *Writer) Marshal(i interface{}) error

Marshal writes a slice of structs to the Writer. The destination interface must of pointer of type slice.

func (*Writer) WriteHeader Uses

func (w *Writer) WriteHeader(i interface{}) error

WriteHeader will write the names of the underlying struct fields as a row. It accepts a struct or a slice of structs.

Package csv imports 7 packages (graph) and is imported by 4 packages. Updated 2019-08-05. Refresh now. Tools for package owners.