25 lines
406 B
Go
25 lines
406 B
Go
|
package config
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"strconv"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func GetInt(key string, fallback int) int {
|
||
|
v := Get(key, strconv.Itoa(fallback))
|
||
|
if out, err := strconv.Atoi(v); err == nil {
|
||
|
return out
|
||
|
}
|
||
|
return fallback
|
||
|
}
|
||
|
|
||
|
func Get(key, fallback string) string {
|
||
|
key = strings.ToUpper(key)
|
||
|
key = strings.ReplaceAll(key, ".", "_")
|
||
|
if v, found := os.LookupEnv(key); found {
|
||
|
return v
|
||
|
}
|
||
|
return fallback
|
||
|
}
|