Skip to content

Commit

Permalink
handle nil
Browse files Browse the repository at this point in the history
  • Loading branch information
sdghchj committed Jun 5, 2020
1 parent be9cf53 commit 83cc237
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ func shouldInitializeField(field reflect.Value, tag string) bool {
case reflect.Struct:
return true
case reflect.Ptr:
if field.Interface() != nil && field.Elem().Kind() == reflect.Struct {
if !field.IsNil() && field.Elem().Kind() == reflect.Struct {
return true
}
case reflect.Slice:
return field.Len() > 0 || tag != ""
}

return (tag != "")
return tag != ""
}

// CanUpdate returns true when the given value is an initial value of its type
Expand Down

0 comments on commit 83cc237

Please sign in to comment.