package config import ( "encoding/json" "os" "git.pyer.club/kingecg/gologger" ) type ServerConfig struct { Host string `json:"host"` Port int `json:"port"` Logging gologger.LoggersConfig `json:"logging"` } var config ServerConfig = ServerConfig{ Host: "0.0.0.0", Port: 8080, Logging: gologger.LoggersConfig{ Appenders: map[string]gologger.LogAppenderConfig{ "out": gologger.LogAppenderConfig{ Type: "console", }, }, Categories: map[string]gologger.LogConfig{ "default": { Level: "debug", Appenders: []string{"out"}, }}, }, } func LoadConfig(configFile string) { // read config gile content and parse it as json configContent, err := os.ReadFile(configFile) if err != nil { panic(err) } err = json.Unmarshal(configContent, &config) if err != nil { panic(err) } } func GetConfig() *ServerConfig { return &config }