Skip to content

Commit

Permalink
Make Lookup() public for symmetry
Browse files Browse the repository at this point in the history
  • Loading branch information
aeijdenberg committed Jul 10, 2018
1 parent ec7986c commit cfec663
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (v *VarSet) AppendSource(s Lookup) *VarSet {
// String gets the string environment variable with the given name, if set.
// If not found, returns defaultVal.
func (v *VarSet) String(name, defaultVal string) string {
rv, ok := v.load(name)
rv, ok := v.Lookup(name)
if !ok {
return defaultVal
}
Expand All @@ -53,7 +53,7 @@ func (v *VarSet) String(name, defaultVal string) string {
// If desired, callers can use IsVarNotFound when recovering from the panic in
// order to check type of the error.
func (v *VarSet) MustString(name string) string {
rv, ok := v.load(name)
rv, ok := v.Lookup(name)
if !ok {
panic(&varNotFoundError{name: name})
}
Expand All @@ -64,7 +64,7 @@ func (v *VarSet) MustString(name string) string {
// If not found, returns false.
// If found and cannot parse, returns an error.
func (v *VarSet) Bool(name string) (bool, error) {
val, ok := v.load(name)
val, ok := v.Lookup(name)
if !ok {
return false, nil
}
Expand All @@ -82,7 +82,7 @@ func (v *VarSet) Bool(name string) (bool, error) {
// If desired, callers can use IsVarNotParsable when recovering from the panic
// in order to check type of the error.
func (v *VarSet) MustBool(name string) bool {
val, ok := v.load(name)
val, ok := v.Lookup(name)
if !ok {
return false
}
Expand All @@ -100,7 +100,7 @@ func (v *VarSet) MustBool(name string) bool {
// If desired, callers can use IsVarNotFound and IsVarNotParsable when
// recovering from the panic in order to check type of the error.
func (v *VarSet) MustHexEncodedByteArray(name string, decodedByteLength int) []byte {
rv, ok := v.load(name)
rv, ok := v.Lookup(name)
if !ok {
panic(&varNotFoundError{name: name})
}
Expand All @@ -114,9 +114,9 @@ func (v *VarSet) MustHexEncodedByteArray(name string, decodedByteLength int) []b
return byteRv
}

// load looks for a given name within all lookup sources.
// Lookup looks for a given name within all lookup sources in order.
// If no variable is found, an empty string and false is returned.
func (v *VarSet) load(name string) (string, bool) {
func (v *VarSet) Lookup(name string) (string, bool) {
for _, lookup := range v.sources {
rv, ok := lookup(name)
if ok {
Expand Down

0 comments on commit cfec663

Please sign in to comment.