Marshaller / Unmarshaller for the BCSV format
go get -u github.com/gouniverse/[email protected]
- Using array
import "github.com/gouniverse/bcsv"
rows := [][]string{}
rows = append(rows, []string{"city", "country"})
rows = append(rows, []string{"Sofia", "BG"})
rows = append(rows, []string{"London", "UK"})
bcsvString, _ := bcsv.MarshalToString(rows)
- Using struct
import "github.com/gouniverse/bcsv"
type Address struct {
City string `bcsv:"city"`
Country string `bcsv:"country"`
}
addressRows := []Address{
{
City: "Sofia",
Country: "BG",
},
{
City: "London",
Country: "UK",
},
}
bcsvString, _ := bcsv.MarshalToString(addressRows)