Skip to content

Commit

Permalink
🐛 fix: read value for field
Browse files Browse the repository at this point in the history
  • Loading branch information
0xE8551CCB committed Oct 21, 2019
1 parent 78698f3 commit 0367bd9
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down

0 comments on commit 0367bd9

Please sign in to comment.