This commit is contained in:
oneao committed 2026-04-16 21:29:38 +08:00
1 parent 6300778150
commit e893ef2e48
27 files changed
+870 -33

No files matched your search

@@ -7,11 +7,13 @@ type Config struct {
JWT JwtConfig `mapstructure:"jwt"`
UniqueID UniqueIDConfig `mapstructure:"unique_id"`
Postgres PostgresConfig `mapstructure:"postgres"`
Wechat WechatConfig `mapstructure:"wechat"`
}
type AppConfig struct {
Name string `mapstructure:"name"`
Port int `mapstructure:"port"`
Name string `mapstructure:"name"`
Port int `mapstructure:"port"`
BaseUrl string `mapstructure:"base_url"`
}
type PostgresConfig struct {
@@ -36,3 +38,8 @@ type UniqueIDConfig struct {
DataCenterID uint16 `mapstructure:"datacenter_id"`
WorkerID uint16 `mapstructure:"worker_id"`
}
type WechatConfig struct {
AppId string `mapstructure:"app_id"`
AppSecret string `mapstructure:"app_secret"`
}
@@ -52,6 +52,7 @@ func Load() (*Config, error) {
func setDefaults(v *viper.Viper) {
v.SetDefault("app.name", "allapp-go")
v.SetDefault("app.port", 8080)
v.SetDefault("app.base_url", "app")
// 可以继续扩展
v.SetDefault("unique_id.datacenter_id", 1)