Skip to content

Commit

Permalink
修复配置文件修改后自动监控发生的数据竞争问题,
Browse files Browse the repository at this point in the history
  • Loading branch information
snowlyg committed Jun 10, 2022
1 parent 4dd5c23 commit 69d5568
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 336 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ func getViperConfig() viper_server.ViperConfig {
}
// 监控配置文件变化
vi.SetConfigName(configName)
vi.WatchConfig()
vi.OnConfigChange(func(e fsnotify.Event) {
fmt.Println("配置发生变化:", e.Name)
if err := vi.Unmarshal(&CONFIG); err != nil {
fmt.Printf("反序列化错误: %v \n", err)
}
})
return nil
},
// 注意:设置默认配置值的时候,前面不能有空格等其他符号.必须紧贴左侧.
Expand Down
7 changes: 0 additions & 7 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ func getViperConfig() viper_server.ViperConfig {
}
// config file change
vi.SetConfigName(configName)
vi.WatchConfig()
vi.OnConfigChange(func(e fsnotify.Event) {
fmt.Println("config file change:", e.Name)
if err := vi.Unmarshal(&CONFIG); err != nil {
fmt.Printf("deserialization data error: %v \n", err)
}
})
return nil
},
// Note: When setting the default configuration value, there can be no other symbols such as spaces in front. It must be close to the left
Expand Down
7 changes: 0 additions & 7 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ func getViperConfig() viper_server.ViperConfig {
}
// config file change
vi.SetConfigName(configName)
vi.WatchConfig()
vi.OnConfigChange(func(e fsnotify.Event) {
fmt.Println("config file change:", e.Name)
if err := vi.Unmarshal(&CONFIG); err != nil {
fmt.Printf("deserialization data error: %v \n", err)
}
})
return nil
},
// Note: When setting the default configuration value, there can be no other symbols such as spaces in front. It must be close to the left
Expand Down
20 changes: 9 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/mattn/go-colorable v0.1.12
github.com/robfig/cron/v3 v3.0.1
github.com/snowlyg/helper v0.0.7
github.com/spf13/viper v1.8.1
github.com/spf13/viper v1.12.0
github.com/unrolled/secure v1.0.9
go.uber.org/zap v1.19.1
gorm.io/driver/mysql v1.1.2
Expand All @@ -36,7 +36,6 @@ require (
github.com/Shopify/goreferrer v0.0.0-20210630161223-536fa16abd6f // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
Expand All @@ -49,7 +48,6 @@ require (
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/goccy/go-json v0.9.8-0.20220506185958-23bd66f4c0d5 // indirect
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
Expand All @@ -64,6 +62,7 @@ require (
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.6.2 // indirect
github.com/jackc/pgx/v4 v4.10.1 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.2 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
Expand All @@ -77,26 +76,25 @@ require (
github.com/klauspost/compress v1.15.6 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lestrrat-go/strftime v1.0.5 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mailgun/raymond/v2 v2.0.46 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/microcosm-cc/bluemonday v1.0.18 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/schollz/closestmatch v2.1.0+incompatible // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.7.2 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/tdewolff/minify/v2 v2.11.9 // indirect
github.com/tdewolff/parse/v2 v2.5.33 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
Expand All @@ -111,7 +109,7 @@ require (
golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit 69d5568

Please sign in to comment.