Open tooodooo opened 2 years ago
Have you tried adding a custom unmarshaler for ItemBase? eg:
import "encoding/json"
func (i *ItemBase) UnmarshalCSV(csv string) error {
return json.Unmarshal([]byte(csv), i)
}
This may not be useful to you, since I couldn't find a previous version that marshaled to that format. My guess is that the csv is coming from somewhere else. But if you also wanted to output you would also need a custom marshaler and add json struct tags. eg:
type ItemBase struct {
Items uint32 `json:"items"`
Count uint32 `json:"count"`
RandomAttributes string `json:"randomAttributes,omitempty"`
Quality uint32 `json:"quality,omitempty"`
}
func (i *ItemBase) MarshalCSV() (string, error) {
b, err := json.Marshal(i)
return string(b), err
}
csv:
go struct:
with this version: github.com/gocarina/gocsv v0.0.0-20220823132111-71f3a5cb2654 work well. but github.com/gocarina/gocsv v0.0.0-20221105105431-c8ef78125b99 can not work. AdventureBoxConf.Key is nil.
Maybe the CSV format is not rigorous enough?