jszwec / csvutil

csvutil provides fast and idiomatic mapping between CSV and Go (golang) values.
MIT License
944 stars 62 forks source link

Feature request: Dynamic field filtering #41

Closed liranms closed 3 years ago

liranms commented 3 years ago

It is sometime desired to use a single struct to generate multiple CSVs, with a subset of the fields in each run Currently, the only way to ignore fields is using tag csv:"-" which is fixed at compile time which makes it impossible to decide which fields should be encoded at runtime I'm proposing a simple solution to add an optional FieldFilter func that accepts csv field name and return true to include the field or not, this would be a property of the Encoder similar to Tag and Autoheader