13 lines
298 B
Go
13 lines
298 B
Go
package toolkit
|
|
|
|
import "os"
|
|
|
|
// EnvOr returns the value of the given environment variable, or the return of
|
|
// the given callback if the environment variable isn't set.
|
|
func EnvOr(name string, fallback func() string) string {
|
|
if v := os.Getenv(name); v != "" {
|
|
return v
|
|
}
|
|
return fallback()
|
|
}
|