Files
wk-backend/internal/conf/var.go
2026-04-03 14:24:29 +08:00

54 lines
1011 B
Go

package conf
import (
"os"
"strings"
"sync/atomic"
)
// 构建信息
var (
Mode string = "debug"
Version string = "unknown"
BuildAt string = "unknown"
GitAuthor string = "unknown"
GitEmail string = "unknown"
GitCommit string = "unknown"
DebugProxy string = ""
DebugSkipSSLVerify bool = false
runtimeDebugEnabled atomic.Bool
)
func init() {
if proxy := os.Getenv("CKWK_DEBUG_PROXY"); proxy != "" {
DebugProxy = proxy
}
DebugSkipSSLVerify = parseEnvBool("CKWK_DEBUG_SKIP_SSL_VERIFY")
runtimeDebugEnabled.Store(parseEnvBool("CKWK_DEBUG_ENABLED"))
}
func IsBuildDebugMode() bool {
return !strings.EqualFold(Mode, "release")
}
func IsRuntimeDebugEnabled() bool {
return runtimeDebugEnabled.Load()
}
func SetRuntimeDebugEnabled(enabled bool) {
runtimeDebugEnabled.Store(enabled)
}
func parseEnvBool(key string) bool {
value := strings.TrimSpace(os.Getenv(key))
switch strings.ToLower(value) {
case "1", "true", "yes", "on":
return true
default:
return false
}
}