mirror of
https://github.com/imjasonh/csvstruct
synced 2026-07-12 07:58:54 +00:00
add godoc
This commit is contained in:
parent
46201aaf1f
commit
f5a423c821
1 changed files with 3 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue