How to create a csv file in memory with golang

Sometimes you need to create an automatic report (invoice, bill) in CSV format. In such cases, it would be appropriate to keep it on blob storage instead of the server(container) disk. Now let’s see how we can do it using memory without saving to disk at all. package csvmanager import ( "bytes" "encoding/csv" "errors" ) func WriteAll(records [][]string) ([]byte, error) { if records == nil || len(records) == 0 { return nil, errors....

October 14, 2020 · 1 min · 166 words · Mecit Semerci