Skip to content

Commit

Permalink
Merge branch 'master' into disable-defaults-slice
Browse files Browse the repository at this point in the history
  • Loading branch information
vrischmann committed Aug 29, 2016
2 parents 9dd087a + ba09a3c commit 757beaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ go:
- 1.2
- 1.3
- 1.4
- 1.5
- 1.6
- 1.7
- tip
14 changes: 7 additions & 7 deletions envconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func parseTag(s string) *tag {
return &t
}

func readStruct(value reflect.Value, ctx *context) (nonnil bool, err error) {
func readStruct(value reflect.Value, ctx *context) (nonNil bool, err error) {
var parents []reflect.Value

for i := 0; i < value.NumField(); i++ {
Expand Down Expand Up @@ -173,16 +173,16 @@ func readStruct(value reflect.Value, ctx *context) (nonnil bool, err error) {
field = field.Elem()
goto doRead
case reflect.Struct:
var nonnilin bool
nonnilin, err = readStruct(field, &context{
var nonNilIn bool
nonNilIn, err = readStruct(field, &context{
name: combineName(ctx.name, name),
optional: ctx.optional || tag.optional,
defaultVal: tag.defaultVal,
parents: parents,
leaveNil: ctx.leaveNil,
allowUnexported: ctx.allowUnexported,
})
nonnil = nonnil || nonnilin
nonNil = nonNil || nonNilIn
default:
var ok bool
ok, err = setField(field, &context{
Expand All @@ -194,21 +194,21 @@ func readStruct(value reflect.Value, ctx *context) (nonnil bool, err error) {
leaveNil: ctx.leaveNil,
allowUnexported: ctx.allowUnexported,
})
nonnil = nonnil || ok
nonNil = nonNil || ok
}

if err != nil {
return false, err
}
}

if !nonnil && ctx.leaveNil { // re-zero
if !nonNil && ctx.leaveNil { // re-zero
for _, p := range parents {
p.Set(reflect.Zero(p.Type()))
}
}

return nonnil, err
return nonNil, err
}

var byteSliceType = reflect.TypeOf([]byte(nil))
Expand Down

0 comments on commit 757beaa

Please sign in to comment.