Skip to content

Commit

Permalink
Merge pull request #20 from wrfly/fix/value-panic
Browse files Browse the repository at this point in the history
fix: check interface value
  • Loading branch information
wrfly authored Aug 28, 2023
2 parents 94722b6 + 6633c2b commit 40f2106
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions get.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ func (e *ecp) getValue(config interface{}, keyName string) (reflect.Value, error
if !v.IsValid() {
return reflect.Value{}, fmt.Errorf("key %s not found", keyName)
}

if !v.CanInterface() {
return reflect.Value{}, fmt.Errorf("bad structure field %s", keyName)
}
return v, nil
}

Expand Down

0 comments on commit 40f2106

Please sign in to comment.