fix(ci): 修复 golangci-lint 和 API 合约测试失败

- 修复 errcheck: singleflight 返回值类型断言添加 ok 检查
- 修复 gofmt: 格式化 setting_service.go 和 claude_code_validator_test.go
- 修复 TestAPIContracts: 在 GET /admin/settings 期望中添加 min_claude_code_version 字段
This commit is contained in:
QTom
2026-03-01 16:39:21 +08:00
parent 4280aca82c
commit b2141a96e2
3 changed files with 20 additions and 16 deletions

View File

@@ -891,7 +891,7 @@ func (s *SettingService) GetMinClaudeCodeVersion(ctx context.Context) string {
}
}
// singleflight: 同一时刻只有一个 goroutine 查询 DB其余复用结果
result, _, _ := minVersionSF.Do("min_version", func() (interface{}, error) {
result, _, _ := minVersionSF.Do("min_version", func() (any, error) {
// 二次检查,避免排队的 goroutine 重复查询
if cached, ok := minVersionCache.Load().(*cachedMinVersion); ok {
if time.Now().UnixNano() < cached.expiresAt {
@@ -917,7 +917,10 @@ func (s *SettingService) GetMinClaudeCodeVersion(ctx context.Context) string {
})
return value, nil
})
return result.(string)
if s, ok := result.(string); ok {
return s
}
return ""
}
// SetStreamTimeoutSettings 设置流超时处理配置