mirror of
https://github.com/github/codeql.git
synced 2026-01-30 06:42:57 +01:00
We've had to tell people how to do this, so we should have a name for it that doesn't refer to a defunct company.
21 lines
472 B
Go
21 lines
472 B
Go
package util
|
|
|
|
import "os"
|
|
|
|
// Getenv retrieves the value of the environment variable named by the key.
|
|
// If that variable is not present, it iterates over the given aliases until
|
|
// it finds one that is. If none are present, the empty string is returned.
|
|
func Getenv(key string, aliases ...string) string {
|
|
val := os.Getenv(key)
|
|
if val != "" {
|
|
return val
|
|
}
|
|
for _, alias := range aliases {
|
|
val = os.Getenv(alias)
|
|
if val != "" {
|
|
return val
|
|
}
|
|
}
|
|
return ""
|
|
}
|