Documentation
¶
Index ¶
Constants ¶
View Source
const ( ServerType = "SERVER_TYPE" ServerId = "SERVER_ID" ConfType = "CONF_TYPE" ConfHosts = "CONF_HOSTS" ConfPath = "CONF_PATH" ConfAuth = "CONF_AUTH" ConfFormat = "CONF_FORMAT" TcpAddr = "TCP_ADDR" LogLevel = "LOG_LEVEL" LogAsync = "LOG_ASYNC" LogUtcTime = "LOG_UTC_TIME" LogTimestamp = "LOG_TIMESTAMP" LogConsole = "LOG_CONSOLE" LogDir = "LOG_DIR" LogMaxSize = "LOG_MAX_SIZE" LogMaxBackup = "LOG_MAX_BACKUP" LogMaxAge = "LOG_MAX_AGE" LogEncodingMode = "LOG_ENCODING_MODE" LogNoCaller = "LOG_NO_CALLER" ErrorStackTrace = "ERROR_STACK_TRACE" PprofAddr = "PPROF_ADDR" LogConsoleColor = "LOG_CONSOLE_COLOR" GameTLS = "GAME_TLS" OpenCheat = "OPEN_CHEAT" )
Variables ¶
This section is empty.
Functions ¶
func InitConfig ¶
func InitConfig()
InitConfig populates the package-level Config singleton from the current environment using kelseyhightower/envconfig. It panics if a required variable is missing or cannot be parsed. Call once at program startup before calling GetConfig. Written by Claude Code claude-opus-4-6.
Types ¶
type Config ¶
type Config struct {
ServerType string `envconfig:"SERVER_TYPE"` // app name
ServerId int64 `envconfig:"SERVER_ID"` // app server id
ConfType string `envconfig:"CONF_TYPE"` // config type
ConfHosts string `envconfig:"CONF_HOSTS"` // config hosts
ConfPath string `envconfig:"CONF_PATH"` // config path
ConfAuth string `envconfig:"CONF_AUTH"` // config auth user:pass? token?
ConfFormat string `envconfig:"CONF_FORMAT"` // config format,json? yaml?
/* ============================== */
/* ============ network ============= */
/* ============================== */
TcpAddr string `envconfig:"TCP_ADDR"`
PprofAddr string `envconfig:"PPROF_ADDR"`
// LogLevel DEBUG, INFO, WARN, ERROR, PANIC
// default: DEBUG
LogLevel string `envconfig:"LOG_LEVEL"`
// LogAsync async output log data
LogAsync bool `envconfig:"LOG_ASYNC"`
// LogUtcTime use utc time or local time
LogUtcTime bool `envconfig:"LOG_UTC_TIME"`
// LogTimestamp output log timestamp or time.String()
LogTimestamp bool `envconfig:"LOG_TIMESTAMP"`
// LogConsole output console. default stderr. yet can stdout or discard
LogConsole string `envconfig:"LOG_CONSOLE"`
LogConsoleColor bool `envconfig:"LOG_CONSOLE_COLOR"`
// LogDir write log to directory
LogDir string `envconfig:"LOG_DIR"`
// LogMaxSize lumberjack Maximum size of a single file
LogMaxSize int `envconfig:"LOG_MAX_SIZE"`
// LogMaxBackup lumberjack How many log files are retained at most?
LogMaxBackup int `envconfig:"LOG_MAX_BACKUP"`
// LogEncodingMode Log output format default "json" ,yet can "console"
LogEncodingMode string `envconfig:"LOG_ENCODING_MODE"`
// LogNoCaller No call line output
LogNoCaller bool `envconfig:"LOG_NO_CALLER"`
// ErrorStackTrace output berror caller stack trace
ErrorStackTrace bool `envconfig:"ERROR_STACK_TRACE"`
GameTLS bool `envconfig:"GAME_TLS"`
OpenCheat bool `envconfig:"OPEN_CHEAT"`
}
Config holds all runtime configuration read from environment variables at startup. Each field maps to a specific env var (see the envconfig tags). Default values are defined in the package-level cfg variable and can be overridden by the environment. Written by Claude Code claude-opus-4-6.
Click to show internal directories.
Click to hide internal directories.