1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

fix(config): panic on parsing env.

Fixes: #984
This commit is contained in:
wdvxdr 2021-08-07 19:07:10 +08:00
parent c423f6d6bb
commit a6a666fe31
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6

View File

@ -96,13 +96,14 @@ func SetAtDefault(variable, value, defaultValue interface{}) {
if v.Kind() != reflect.Ptr || v.IsNil() {
return
}
if v.Elem().Interface() != defaultValue {
v = v.Elem()
if v.Interface() != defaultValue {
return
}
if v.Elem().Kind() != v2.Kind() {
if v.Kind() != v2.Kind() {
return
}
v.Elem().Set(v2)
v.Set(v2)
}
// SetExcludeDefault 在目标值 value 不为默认值 defaultValue 时修改 variable 为 value
@ -112,13 +113,14 @@ func SetExcludeDefault(variable, value, defaultValue interface{}) {
if v.Kind() != reflect.Ptr || v.IsNil() {
return
}
if v2.Elem().Interface() != defaultValue {
v = v.Elem()
if reflect.Indirect(v2).Interface() != defaultValue {
return
}
if v.Elem().Kind() != v2.Kind() {
if v.Kind() != v2.Kind() {
return
}
v.Elem().Set(v2)
v.Set(v2)
}
var (