Skip to content

Commit

Permalink
envflag nil guard on MustBool and MustInt
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Dec 18, 2023
1 parent c049be7 commit ea013a3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions envflag/envflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func MustBool(name string, defaultValue bool, usage string) *bool {
panic(err)
}
}
if res == nil { // should never happen, guard added for NilAway
panic(fmt.Sprintf("MustBool res for '%s' is nil", name))
}
return res
}

Expand Down Expand Up @@ -81,6 +84,11 @@ func MustInt(name string, defaultValue int, usage string) *int {
panic(err)
}
}

if res == nil { // should never happen, guard added for NilAway
panic(fmt.Sprintf("MustInt res for '%s' is nil", name))
}

return res
}

Expand Down

0 comments on commit ea013a3

Please sign in to comment.