fix(lint): 修复所有golangci-lint错误

- 修复depguard错误:为ops service文件添加redis导入例外
- 修复errcheck错误:添加错误检查和类型断言检查
- 修复gofmt错误:格式化代码
- 修复ineffassign错误:移除无效的idx++赋值
- 修复staticcheck错误:合并条件赋值
- 修复unused错误:移除未使用的字段和函数
  - ops_cleanup_service.go: entryID字段
  - ops_retry.go: status字段
  - ops_upstream_context.go: getOpsUpstreamErrors函数
This commit is contained in:
IanShaw027
2026-01-11 23:26:29 +08:00
parent 4cb7b26f03
commit 54c5788b86
13 changed files with 15 additions and 32 deletions

View File

@@ -44,8 +44,7 @@ type OpsCleanupService struct {
instanceID string
cron *cron.Cron
entryID cron.EntryID
cron *cron.Cron
startOnce sync.Once
stopOnce sync.Once

View File

@@ -51,7 +51,6 @@ const (
type limitedResponseWriter struct {
header http.Header
status int
wroteHeader bool
limit int

View File

@@ -62,10 +62,7 @@ func NewOpsScheduledReportService(
redisClient *redis.Client,
cfg *config.Config,
) *OpsScheduledReportService {
lockOn := true
if cfg != nil && strings.TrimSpace(cfg.RunMode) == config.RunModeSimple {
lockOn = false
}
lockOn := cfg == nil || strings.TrimSpace(cfg.RunMode) != config.RunModeSimple
loc := time.Local
if cfg != nil && strings.TrimSpace(cfg.Timezone) != "" {

View File

@@ -80,18 +80,6 @@ func appendOpsUpstreamError(c *gin.Context, ev OpsUpstreamErrorEvent) {
c.Set(OpsUpstreamErrorsKey, existing)
}
func getOpsUpstreamErrors(c *gin.Context) []*OpsUpstreamErrorEvent {
if c == nil {
return nil
}
if v, ok := c.Get(OpsUpstreamErrorsKey); ok {
if arr, ok := v.([]*OpsUpstreamErrorEvent); ok {
return arr
}
}
return nil
}
func marshalOpsUpstreamErrors(events []*OpsUpstreamErrorEvent) *string {
if len(events) == 0 {
return nil