fix: tag split handling
This commit is contained in:
parent
46f412ac29
commit
73e9aafbfd
1 changed files with 2 additions and 2 deletions
4
gapr.go
4
gapr.go
|
@ -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])
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue