polycule-connect/polyculeconnect/config/envvar.go
Melora Hugues 4909df4b04
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful
feat #37: Use environment variables for most of the configuration
2023-10-28 14:20:40 +02:00

26 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
}