mirror of https://github.com/bjdgyc/anylink.git
删除文件不存在的报错信息
This commit is contained in:
parent
cd8922237f
commit
a616e42432
|
@ -1,6 +1,7 @@
|
||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
@ -63,7 +64,13 @@ func init() {
|
||||||
viper.SetConfigFile(cfgFile)
|
viper.SetConfigFile(cfgFile)
|
||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
err := viper.ReadInConfig()
|
_, err := os.Stat(cfgFile)
|
||||||
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
|
// 文件不存在,不做处理
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = viper.ReadInConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Using config file:", err)
|
fmt.Println("Using config file:", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue