github.com/jimsmart/peanut (go): Package peanut writes tagged data structs to disk in a variety of formats. Its primary purpose is to provide a single consistent interface for easy, ceremony-free persistence of record-based struct data.  Each distinct struct type is written to an individual file (or table), automatically created, each named according to the name of the struct. Field/column names in each file/table are derived from struct tags. All writers use the same tags.  Currently supported formats are CSV, TSV, Excel (.xlsx), JSON Lines (JSONL), and SQLite. Additional writers are also provided to assist with testing and debugging. Mutiple writers can be combined using MultiWriter.  All writers have the same basic interface: a Write method, that can take any appropriately tagged struct; a Close method, which should be called to successfully complete writing; and a Cancel method, which should be called to abort writing and clean-up, in the event of an error or cancellation. It is safe to make mulltiple calls to Cancel, and it is safe to call Close after having previously called Cancel.  All writers output their files atomically — that is to say: all output is written to a temporary location and only moved to the final output location when Close is called, meaning the output folder never contains any partially written files.  Structs to be used with peanut must have appropriately tagged fields, for example:  Fields without tags do not get written as output.  First create a writer, for example:  Next, write some records to it:  When successfully completed:  Or, to abort the whole operation in the event of an error or cancellation while writing records:  Multiple writers can be combined using MultiWriter:  Here w will write records to CSV files, Excel files, and a logger.  Behaviour is undefined for types with the same name but in different packages, such as package1.Foo and package2.Foo.  Supported datatypes for struct fields: string, bool, float32, float64, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64.  Pointer following and nested structs are currently unsupported.  Tagging a field that has an unsupported datatype will result in a error when Write is called.
Keywords: csv|excel|go|jsonl|log-file|sqlite|struct-writer|tsv