1
0
Fork 0
mirror of https://github.com/imjasonh/csvstruct synced 2026-07-12 07:58:54 +00:00

add godoc

This commit is contained in:
Jason Hall 2014-05-15 13:44:46 -04:00
parent 46201aaf1f
commit f5a423c821

View file

@ -7,6 +7,7 @@ import (
"reflect"
)
// Encoder encodes and writes CSV rows to an output stream.
type Encoder interface {
EncodeNext(v interface{}) error
}
@ -16,10 +17,12 @@ type encoder struct {
headersWritten bool
}
// NewEncoder returns an encoder that writes to w.
func NewEncoder(w io.Writer) Encoder {
return &encoder{w: csv.NewWriter(w)}
}
// EncodeNext writes the CSV encoding of v to the stream.
func (e *encoder) EncodeNext(v interface{}) error {
t := reflect.ValueOf(v).Type()
if !e.headersWritten {