package config type Config struct { Server *ServerConfig `toml:"server" json:"server" comment:"服务配置"` Debug *DebuggerConfig `toml:"debug" json:"debug" comment:"调试模式"` } type ServerConfig struct { Host string `toml:"host" json:"host" comment:"监听ip"` Port int `toml:"port" json:"port" comment:"监听端口"` } type DebuggerConfig struct { Enable bool `toml:"enable" json:"enable" comment:"启用"` } func (c *Config) HasDebug() bool { return c.Debug != nil } func DefaultConfig() *Config { return &Config{ Server: &ServerConfig{ Host: "localhost", Port: 32323, }, } }