mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
19 lines
450 B
Go
19 lines
450 B
Go
package env
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// Lookup is the equivalent of os.LookupEnv, only you are able to provide the list of environment variables.
|
|
// To use this as os.LookupEnv would be used, simply call
|
|
// `env.Lookup("ENVIRONMENT_VARIABLE", os.Environ())`
|
|
func Lookup(name string, vars []string) (string, bool) {
|
|
for _, v := range vars {
|
|
if strings.HasPrefix(v, name) {
|
|
return strings.TrimPrefix(v, name+"="), true
|
|
}
|
|
}
|
|
|
|
return "", false
|
|
}
|