DEVELOPMENT ENVIRONMENT

~liljamo/erya-go

3201c2bf8ec783dc201473a3e2857a90fcd64b2a — Jonni Liljamo 1 year, 1 month ago 240b763 0.1.0
feat: util load int32 env
1 files changed, 14 insertions(+), 0 deletions(-)

M util/env.go
M util/env.go => util/env.go +14 -0
@@ 26,6 26,20 @@ func LoadEnvStr(key string, def string) string {
	return def
}

func LoadEnvInt32(key string, def int32) int32 {
	value, found := os.LookupEnv(key)
	if found {
		res, err := strconv.ParseInt(value, 10, 32)
		if err != nil {
			log.Fatalf("[erya] Environment variable %s failed to parse to int32 from '%s'", key, value)
		}
		return int32(res)
	}

	log.Printf("[erya] Environment variable %s is empty, using default '%d'", key, def)
	return def
}

func LoadEnvBool(key string, def bool) bool {
	value, found := os.LookupEnv(key)
	if found {