Skip to content

Commit a39b9f0

Browse files
committed
fix(config): 修复更新配置检测中的空指针问题
- 添加了对 Config.Update 是否为 nil 的检查和初始化 - 设置默认镜像源为 "ghproxy" 当未指定时 - 确保 custom 镜像源时 customURL 不为空校验逻辑完整
1 parent e606948 commit a39b9f0

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

internal/config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func validateConfig() error {
105105
}
106106

107107
// 验证更新配置
108+
if Config.Update == nil {
109+
Config.Update = &UpdateConfig{}
110+
}
108111
if Config.Update.Mirror != "" {
109112
validMirrors := []string{"github", "ghproxy", "ghproxy2", "custom"}
110113
isValid := slices.Contains(validMirrors, Config.Update.Mirror)
@@ -116,6 +119,8 @@ func validateConfig() error {
116119
if Config.Update.Mirror == "custom" && Config.Update.CustomURL == "" {
117120
return errors.New("使用 custom 镜像源时,customUrl 不能为空")
118121
}
122+
} else {
123+
Config.Update.Mirror = "ghproxy"
119124
}
120125

121126
return nil

0 commit comments

Comments
 (0)