From 0367bd96189610b0e713b9b253d9a1f1057d6214 Mon Sep 17 00:00:00 2001 From: 0xE8551CCB Date: Mon, 21 Oct 2019 15:12:13 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20read=20value=20for=20fiel?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- schema.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/schema.go b/schema.go index 37abb7d..28f60f9 100644 --- a/schema.go +++ b/schema.go @@ -128,7 +128,6 @@ func (s *schema) fieldValueFromSrc(ctx context.Context, field *schemaField, v in return nil, fmt.Errorf("failed to get value for field %s, empty input data %v", field, v) } - src := structs.New(v) if field.hasConstValue() { val = field.constValue() } else if field.hasMethod() { @@ -140,18 +139,7 @@ func (s *schema) fieldValueFromSrc(ctx context.Context, field *schemaField, v in } else if field.hasChainingAttrs() { return nestedValue(ctx, v, field.chainingAttrs()) } else { - if field.isNested() { - return nestedValue(ctx, v, []string{field.Name()}) - } else { - f, ok := src.FieldOk(field.Name()) - if ok { - val = f.Value() - } else { - v, e := nestedValue(ctx, v, []string{field.Name()}) - val = v - err = e - } - } + return nestedValue(ctx, v, []string{field.Name()}) } return