From 73e9aafbfd3c5977c9dbab7a874b3ea2373977d3 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Mon, 30 Jan 2023 17:59:21 +0100 Subject: [PATCH] fix: tag split handling --- gapr.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gapr.go b/gapr.go index 18b2b11..550810c 100644 --- a/gapr.go +++ b/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]) }