csv decoder.
$ go get -u github.com/sodefrin/csv-decoder
requirements: go1.13
package main
import (
"fmt"
"log"
"strings"
csvdecoder "github.com/sodefrin/csv-decoder"
)
type sample struct {
Test1 string
Test2 int
}
func main() {
out := []*sample{}
// read "Test1,Test2\na,10\n" from filepath and parse
if err := csvdecoder.Decode("filepath", &out); err != nil {
log.Fatal(err)
}
for _, v := range out {
fmt.Printf("%s %d", v.Test1, v.Test2)
// Output:
// a 10
}
}