package global import ( "log" "github.com/BurntSushi/toml" ) type Config struct { Database DatabaseConfig `toml:"database"` App AppConfig `toml:"config"` Logs LogConfig `toml:"logs"` } type AppConfig struct { Ip string `toml:"ip"` Port string `toml:"port"` IsGenerate bool `toml:"is_generate"` } type DatabaseConfig struct { OADBIP string `toml:"oadb_ip"` OADBPort string `toml:"oadb_port"` OADBDb string `toml:"oadb_db"` OADBUser string `toml:"oadb_user"` OADBPass string `toml:"oadb_password"` LicDBIP string `toml:"licdb_ip"` LicDBPort string `toml:"licdb_port"` LicDBDb string `toml:"licdb_db"` LicDBUser string `toml:"licdb_user"` LicDBPass string `toml:"licdb_password"` } type LogConfig struct { LicLog string `toml:"lic_log"` } // LoadConfig 从给定的 TOML 文件路径加载配置 func LoadConfig(filePath string) *Config { var config Config // 读取并解析 TOML 文件 if _, err := toml.DecodeFile(filePath, &config); err != nil { log.Fatalf("无法解析配置文件: %s", err) } return &config }