Skip to content

Commit

Permalink
Fixed pointers processing
Browse files Browse the repository at this point in the history
  • Loading branch information
borisershov committed May 3, 2020
1 parent 01a87ae commit 3a1a091
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ func Load(conf interface{}, s Settings) error {
// setDefaults sets the default values from tags.
func (s *Settings) setDefaults(val reflect.Value, parentName string, dv defaultValue) error {

if val.Kind() == reflect.Ptr && val.IsNil() == true {
return nil
}

// Check val is pointer
if val.Kind() == reflect.Ptr {
val = val.Elem()
Expand Down Expand Up @@ -212,6 +216,10 @@ func (s *Settings) setDefaults(val reflect.Value, parentName string, dv defaultV
// checkUsedRequredOpts checks that config file contains all requirement options
func (s *Settings) checkUsedRequredOpts(val reflect.Value, parentName string) error {

if val.Kind() == reflect.Ptr && val.IsNil() == true {
return nil
}

// Check val is pointer
if val.Kind() == reflect.Ptr {
val = val.Elem()
Expand Down

0 comments on commit 3a1a091

Please sign in to comment.