1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-06 20:13:50 +08:00

fix config.Get() (#808)

配置文件不存在时config.Get()返回非空指针, 导致无法创建默认配置文件
This commit is contained in:
null-su 2021-04-10 11:37:32 +08:00 committed by GitHub
parent 8506d7586f
commit e3c06731e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,9 +122,11 @@ func Get() *Config {
file, err := os.Open(DefaultConfigFile) file, err := os.Open(DefaultConfigFile)
if err != nil { if err != nil {
log.Error("获取配置文件失败: ", err) log.Error("获取配置文件失败: ", err)
return
} }
defer file.Close()
config = &Config{} config = &Config{}
if yaml.NewDecoder(file).Decode(config) != nil { if err = yaml.NewDecoder(file).Decode(config); err != nil {
log.Fatal("配置文件不合法!", err) log.Fatal("配置文件不合法!", err)
} }
}) })