feat: add env DIFY_DEBUG

This commit is contained in:
CalciumIon
2024-07-07 02:24:51 +08:00
parent 4246c4cdc1
commit 20d71711d3
4 changed files with 17 additions and 2 deletions

View File

@@ -24,3 +24,15 @@ func GetEnvOrDefaultString(env string, defaultValue string) string {
}
return os.Getenv(env)
}
func GetEnvOrDefaultBool(env string, defaultValue bool) bool {
if env == "" || os.Getenv(env) == "" {
return defaultValue
}
b, err := strconv.ParseBool(os.Getenv(env))
if err != nil {
SysError(fmt.Sprintf("failed to parse %s: %s, using default value: %t", env, err.Error(), defaultValue))
return defaultValue
}
return b
}