mirror of
https://github.com/imjasonh/csvstruct
synced 2026-07-18 14:56:23 +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"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Encoder encodes and writes CSV rows to an output stream.
|
||||||
type Encoder interface {
|
type Encoder interface {
|
||||||
EncodeNext(v interface{}) error
|
EncodeNext(v interface{}) error
|
||||||
}
|
}
|
||||||
|
|
@ -16,10 +17,12 @@ type encoder struct {
|
||||||
headersWritten bool
|
headersWritten bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewEncoder returns an encoder that writes to w.
|
||||||
func NewEncoder(w io.Writer) Encoder {
|
func NewEncoder(w io.Writer) Encoder {
|
||||||
return &encoder{w: csv.NewWriter(w)}
|
return &encoder{w: csv.NewWriter(w)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EncodeNext writes the CSV encoding of v to the stream.
|
||||||
func (e *encoder) EncodeNext(v interface{}) error {
|
func (e *encoder) EncodeNext(v interface{}) error {
|
||||||
t := reflect.ValueOf(v).Type()
|
t := reflect.ValueOf(v).Type()
|
||||||
if !e.headersWritten {
|
if !e.headersWritten {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue