package config import ( "fmt" "os" "git.sxidc.com/go-framework/baize/framework/core/application" "gopkg.in/yaml.v3" ) type servicesConfig struct { TimeoutSec int64 `yaml:"timeout_sec"` UMBaseUrl string `yaml:"um_base_url"` TMBaseUrl string `yaml:"tm_base_url"` } type GatewayConfig struct { ApplicationConfig application.Config ServicesConfig servicesConfig `yaml:"services"` } var conf = &GatewayConfig{} func init() { configFilePath := os.Getenv("CONFIG_FILE_PATH") applicationConfig, err := application.LoadFromYamlFile(configFilePath) if err != nil { panic(err) } conf.ApplicationConfig = applicationConfig yamlBytes, err := os.ReadFile(configFilePath) if err != nil { panic(err) } err = yaml.Unmarshal(yamlBytes, &conf) if err != nil { panic(err) } fmt.Println("Load config file finish") } func GetGatewayConfig() *GatewayConfig { return conf }