You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
I have a Struct with the following field and tags PartialDeliveryNumber uint `json:"partialDeliveryNumber" csv:"partial_delivery_number"`
I have a test that reads in some json data and uploads it to Redshift. In order to upload this data,
the column names have to be extracted from the records with this function:
// columns are determined by csv tags on the model
func GetColumns[T Model](records []T) ([]string, error) {
var b bytes.Buffer
if err := gocsv.Marshal(records, &b); err != nil {
return nil, fmt.Errorf("failed to marshal csv headers: %w", err)
}
sc := bufio.NewScanner(bytes.NewReader(b.Bytes()))
sc.Scan()
cols := sc.Text()
return strings.Split(cols, ","), nil
}
Problem:
As soon as the Struct Field is named "PartialDeliveryNumber", the csv tag is ignored and "PartialDeliveryNumber" is returned as the column name. If I name the struct as follows, no issues occur: PDN uint `json:"partialDeliveryNumber" csv:"partial_delivery_number"`
After some debugging we found that the issue probably relates to this line in the library:
Description:
I have a Struct with the following field and tags
PartialDeliveryNumber uint `json:"partialDeliveryNumber" csv:"partial_delivery_number"`
I have a test that reads in some json data and uploads it to Redshift. In order to upload this data,
the column names have to be extracted from the records with this function:
Problem:
As soon as the Struct Field is named "PartialDeliveryNumber", the csv tag is ignored and "PartialDeliveryNumber" is returned as the column name. If I name the struct as follows, no issues occur:
PDN uint `json:"partialDeliveryNumber" csv:"partial_delivery_number"`
After some debugging we found that the issue probably relates to this line in the library:
gocsv/reflect.go
Line 228 in b87c2d0
The text was updated successfully, but these errors were encountered: