func (cp *CSVPrinter) Print(inputs []Input) error {
	cp.headers = nil
	cp.record = nil
	for _, input := range inputs {
		for _, datum := range input.data {
			cp.headers = append(cp.headers, datum.header)
			cp.record = append(cp.record, datum.value)
		}
	}
	if !cp.noHeader && !cp.headerPrinted {
		err := cp.csvWriter.Write(cp.headers)
		if err != nil {
			return err
		}
		cp.headerPrinted = true
	}
	return cp.csvWriter.Write(cp.record)
}
Print writes set record to passed writer.
No header is printed if noHeader is set to false.
Print returns an error if writing to writer fails.
package input
import (
	"encoding/csv"
)
type Datum struct {
	header string
	value  string
}
func NewDatum(header string) Datum {
	return Datum{header: header}
}
func (d Datum) WithValue(value string) Datum {
	d.value = value
	return d
}
type CSVPrinter struct {
	csvWriter     *csv.Writer
	headers       []string
	record        []string
	headerPrinted bool
	noHeader      bool
}
func NewCSVPrinter(csvWriter *csv.Writer, noHeader bool) *CSVPrinter {
	return &CSVPrinter{
		csvWriter: csvWriter,
		noHeader:  noHeader,
	}
}