gocarina / gocsv

The GoCSV package aims to provide easy CSV serialization and deserialization to the golang programming language
MIT License
1.99k stars 245 forks source link

Prefix fields of nested struct with tag of nested struct + . #208

Closed acls closed 2 years ago

acls commented 2 years ago

This makes it possible to prefix nested struct fields with the tag of the struct. This also fixes #107 and #168

type NestedSample struct {
    Inner1      InnerStruct       `csv:"one"`
    InnerIgnore InnerStruct       `csv:"-"`
    Inner2      InnerStruct       `csv:"two"`
}

type InnerStruct struct {
    String string `csv:"string"`
}

When marshaling/unmarshaling NestedSample the following headers will be used:

one.string,two.string

Note: This PR builds on my first PR #207.

pikanezi commented 2 years ago

thanks!