Skip to content

Commit

Permalink
两个问题
Browse files Browse the repository at this point in the history
* 默认存储添加开关
* 升级viper到master最新提交,修复Sub方法返回的配置没有继承父配置的数据 @see spf13/viper#1056
  • Loading branch information
zedisdog committed Mar 13, 2023
1 parent babc606 commit 19109c6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 24 deletions.
2 changes: 1 addition & 1 deletion application/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (app *App) Init(config config.IConfig) {
}

func (app *App) initDefaultStorage(config config.IConfig) {
if config != nil {
if config != nil && config.GetBool("enable") {
app.logger.Info("[application] init default storage...")
var driver storage.IDriver
switch config.GetString("driver") {
Expand Down
22 changes: 0 additions & 22 deletions config/viper/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,28 +126,6 @@ func (c *Config) Load() {
c.v.AutomaticEnv()
}

//func (c *config) New(cfg interface{}) (conf config.IConfig, err error) {
// v := viper.New()
// switch c := cfg.(type) {
// case io.Reader:
// err = v.MergeConfig(c)
// case map[string]interface{}:
// err = v.MergeConfigMap(c)
// default:
// err = errx.New("config is invalid")
// }
//
// if err != nil {
// return
// }
//
// conf = &config{
// v: v,
// }
//
// return
//}

func (c *Config) AllSettings() interface{} {
return c.v.AllSettings()
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/iancoleman/strcase v0.2.0
github.com/jinzhu/copier v0.3.5
github.com/sony/sonyflake v1.1.0
github.com/spf13/viper v1.15.0
github.com/spf13/viper v1.15.1-0.20230225211736-3970ad177ecc
github.com/stretchr/testify v1.8.1
go.uber.org/zap v1.21.0
gorm.io/driver/mysql v1.4.7
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,8 @@ github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/y
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU=
github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA=
github.com/spf13/viper v1.15.1-0.20230225211736-3970ad177ecc h1:t5ZYI1Io/lZwVjxojqjV3kqjezTrK78CHuTkXQ6hVug=
github.com/spf13/viper v1.15.1-0.20230225211736-3970ad177ecc/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA=
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down

0 comments on commit 19109c6

Please sign in to comment.