Skip to content

Commit

Permalink
Merge pull request #8 from iFaceless/fix-read-value-for-field
Browse files Browse the repository at this point in the history
🐛 fix: read value for field
  • Loading branch information
iFaceless authored Oct 21, 2019
2 parents 476517f + 0367bd9 commit 76f47c0
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 76f47c0

Please sign in to comment.