Skip to content

Commit

Permalink
envflag nil guard on MustBool and MustInt (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris authored May 23, 2024
1 parent a2aadfa commit a6b2d4e
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 a6b2d4e

Please sign in to comment.