fix: tag split handling

This commit is contained in:
Peter 2023-01-30 17:59:21 +01:00
parent 46f412ac29
commit 73e9aafbfd
No known key found for this signature in database

View file

@ -133,7 +133,7 @@ func (g *Gapr) fieldMeta(f reflect.StructField) (drop bool, fieldName string, er
}
tagSplit := strings.Split(tagVal, ",")
if len(tagSplit) < 2 {
if len(tagSplit) < 1 {
return false, f.Name, nil
}
@ -143,7 +143,7 @@ func (g *Gapr) fieldMeta(f reflect.StructField) (drop bool, fieldName string, er
}
drop = g.rand.Float64() < dropProbability
if tagSplit[1] != "" {
if len(tagSplit) > 1 && tagSplit[1] != "" {
fieldName = strings.TrimSpace(tagSplit[1])
}