Documentation
¶
Overview ¶
Package vinyl creates Records from structs inferring schema from exported fields via reflect. This package can make working with the stdlib "encoding/csv" more ergonomic by supplying a translation layer between structs and csv encoding that doesn't require extra annotation or codegen. All string marhsaling of labels and values is done via fmt.Sprint
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exchange ¶
func Exchange(v interface{}) (ex exchange, err error)
Exchange can read records from a row and translate them into the supplied concrete type. Only types with all exported string fields are supported.
type t stuct{A, B, C string}
recs, _ := vinyl.Exchange(t{})
row, _ := csvreader.Read()
v := recs.From(row).(t)
func Labels ¶
Labels represent the schema of the record and are inferred from the exported Fields of the supplied type Labels are deterministic in their names and order as defined by the supplied type Formatters will be applied in the order they are supplied
func SnakeFormat ¶
SnakeFormat is a formatter to convert labels into snake_case
Types ¶
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
Record is a generic type for holding interface types