polycule-connect/polyculeconnect/config/envvar.go
Melora Hugues 2192775063
Some checks failed
ci/woodpecker/push/deploy unknown status
ci/woodpecker/push/test Pipeline failed
feat #37: Use environment variables for most of the configuration
2023-10-28 14:18:38 +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
}