From 46f412ac29f1884c3cf522932335f8ada58ba77c Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Mon, 30 Jan 2023 17:54:14 +0100 Subject: [PATCH] fix: drop probability handling --- gapr.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gapr.go b/gapr.go index b3fcc04..18b2b11 100644 --- a/gapr.go +++ b/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]) }