fix: drop probability handling
This commit is contained in:
parent
2d8df259cb
commit
46f412ac29
1 changed files with 3 additions and 3 deletions
6
gapr.go
6
gapr.go
|
@ -42,7 +42,7 @@ func (g *Gapr) Map(input any) (any, error) {
|
|||
case reflect.Struct, reflect.Interface:
|
||||
return g.mapStruct(t, v)
|
||||
case reflect.Slice, reflect.Array:
|
||||
return g.mapSliceOrArray(t, v)
|
||||
return g.mapSliceOrArray(v)
|
||||
default:
|
||||
return nil, ErrNotSupportedType
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ func (g *Gapr) mapMap(t reflect.Type, v reflect.Value) (any, error) {
|
|||
return mapped, nil
|
||||
}
|
||||
|
||||
func (g *Gapr) mapSliceOrArray(t reflect.Type, v reflect.Value) (any, error) {
|
||||
func (g *Gapr) mapSliceOrArray(v reflect.Value) (any, error) {
|
||||
var (
|
||||
length = v.Len()
|
||||
target = reflect.ValueOf(make([]any, length, length))
|
||||
|
@ -142,7 +142,7 @@ func (g *Gapr) fieldMeta(f reflect.StructField) (drop bool, fieldName string, er
|
|||
return false, "", err
|
||||
}
|
||||
|
||||
drop = g.rand.Float64() < 1.0-dropProbability
|
||||
drop = g.rand.Float64() < dropProbability
|
||||
if tagSplit[1] != "" {
|
||||
fieldName = strings.TrimSpace(tagSplit[1])
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue