27 lines
418 B
Go
27 lines
418 B
Go
|
package config
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
func getStringFromEnv(key envVar, defaultValue string) string {
|
||
|
val, ok := os.LookupEnv(string(key))
|
||
|
if !ok {
|
||
|
return defaultValue
|
||
|
}
|
||
|
return val
|
||
|
}
|
||
|
|
||
|
func getIntFromEnv(key envVar, defaultValue int) int {
|
||
|
rawVal, ok := os.LookupEnv(string(key))
|
||
|
if !ok {
|
||
|
return defaultValue
|
||
|
}
|
||
|
val, err := strconv.Atoi(rawVal)
|
||
|
if err != nil {
|
||
|
return defaultValue
|
||
|
}
|
||
|
return val
|
||
|
}
|