移除说明
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InitViper 解析yaml格式文件
|
|
||||||
func InitViper(path ...string) {
|
func InitViper(path ...string) {
|
||||||
var confPath string
|
var confPath string
|
||||||
if len(path) == 0 {
|
if len(path) == 0 {
|
||||||
@@ -29,17 +28,13 @@ func InitViper(path ...string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
v := viper.New()
|
v := viper.New()
|
||||||
// 指定配置文件路径
|
|
||||||
v.SetConfigFile(confPath)
|
v.SetConfigFile(confPath)
|
||||||
// 如果配置文件的名称中没有扩展名,则需要配置此项
|
|
||||||
v.SetConfigType("yaml")
|
v.SetConfigType("yaml")
|
||||||
// 查找并读取配置文件
|
|
||||||
err := v.ReadInConfig()
|
err := v.ReadInConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("[-]读取配置文件错误: %s \n", err)
|
fmt.Printf("[-]读取配置文件错误: %s \n", err)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
// 监控并重新读取配置文件
|
|
||||||
v.WatchConfig()
|
v.WatchConfig()
|
||||||
v.OnConfigChange(func(e fsnotify.Event) {
|
v.OnConfigChange(func(e fsnotify.Event) {
|
||||||
if err = v.Unmarshal(&global.AppConf); err != nil {
|
if err = v.Unmarshal(&global.AppConf); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user