MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / GetEnvOrDefault

Function GetEnvOrDefault

common/env.go:9–19  ·  view source on GitHub ↗
(env string, defaultValue int)

Source from the content-addressed store, hash-verified

7)
8
9func GetEnvOrDefault(env string, defaultValue int) int {
10 if env == "" || os.Getenv(env) == "" {
11 return defaultValue
12 }
13 num, err := strconv.Atoi(os.Getenv(env))
14 if err != nil {
15 SysError(fmt.Sprintf("failed to parse %s: %s, using default value: %d", env, err.Error(), defaultValue))
16 return defaultValue
17 }
18 return num
19}
20
21func GetEnvOrDefaultString(env string, defaultValue string) string {
22 if env == "" || os.Getenv(env) == "" {

Callers 5

InitDBFunction · 0.92
InitLogDBFunction · 0.92
InitRedisClientFunction · 0.85
InitEnvFunction · 0.85
initConstantEnvFunction · 0.85

Calls 2

SysErrorFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected