fix(lint): 修复 golangci-lint 报错

- 修复 gofmt 格式问题
- 修复 staticcheck SA4031 nil check 问题(只在成功时设置 release 函数)
- 删除未使用的 sortAccountsByPriority 函数
This commit is contained in:
IanShaw027
2026-01-01 04:26:01 +08:00
parent fe31495a89
commit 9c88980483
4 changed files with 16 additions and 16 deletions

View File

@@ -192,10 +192,12 @@ func (h *GatewayHandler) Messages(c *gin.Context) {
log.Printf("Account wait queue full: account=%d", account.ID) log.Printf("Account wait queue full: account=%d", account.ID)
h.handleStreamingAwareError(c, http.StatusTooManyRequests, "rate_limit_error", "Too many pending requests, please retry later", streamStarted) h.handleStreamingAwareError(c, http.StatusTooManyRequests, "rate_limit_error", "Too many pending requests, please retry later", streamStarted)
return return
} } else {
// Only set release function if increment succeeded
accountWaitRelease = func() { accountWaitRelease = func() {
h.concurrencyHelper.DecrementAccountWaitCount(c.Request.Context(), account.ID) h.concurrencyHelper.DecrementAccountWaitCount(c.Request.Context(), account.ID)
} }
}
accountReleaseFunc, err = h.concurrencyHelper.AcquireAccountSlotWithWaitTimeout( accountReleaseFunc, err = h.concurrencyHelper.AcquireAccountSlotWithWaitTimeout(
c, c,
@@ -314,10 +316,12 @@ func (h *GatewayHandler) Messages(c *gin.Context) {
log.Printf("Account wait queue full: account=%d", account.ID) log.Printf("Account wait queue full: account=%d", account.ID)
h.handleStreamingAwareError(c, http.StatusTooManyRequests, "rate_limit_error", "Too many pending requests, please retry later", streamStarted) h.handleStreamingAwareError(c, http.StatusTooManyRequests, "rate_limit_error", "Too many pending requests, please retry later", streamStarted)
return return
} } else {
// Only set release function if increment succeeded
accountWaitRelease = func() { accountWaitRelease = func() {
h.concurrencyHelper.DecrementAccountWaitCount(c.Request.Context(), account.ID) h.concurrencyHelper.DecrementAccountWaitCount(c.Request.Context(), account.ID)
} }
}
accountReleaseFunc, err = h.concurrencyHelper.AcquireAccountSlotWithWaitTimeout( accountReleaseFunc, err = h.concurrencyHelper.AcquireAccountSlotWithWaitTimeout(
c, c,

View File

@@ -233,10 +233,12 @@ func (h *GatewayHandler) GeminiV1BetaModels(c *gin.Context) {
log.Printf("Account wait queue full: account=%d", account.ID) log.Printf("Account wait queue full: account=%d", account.ID)
googleError(c, http.StatusTooManyRequests, "Too many pending requests, please retry later") googleError(c, http.StatusTooManyRequests, "Too many pending requests, please retry later")
return return
} } else {
// Only set release function if increment succeeded
accountWaitRelease = func() { accountWaitRelease = func() {
geminiConcurrency.DecrementAccountWaitCount(c.Request.Context(), account.ID) geminiConcurrency.DecrementAccountWaitCount(c.Request.Context(), account.ID)
} }
}
accountReleaseFunc, err = geminiConcurrency.AcquireAccountSlotWithWaitTimeout( accountReleaseFunc, err = geminiConcurrency.AcquireAccountSlotWithWaitTimeout(
c, c,

View File

@@ -681,12 +681,6 @@ func (s *GatewayService) tryAcquireAccountSlot(ctx context.Context, accountID in
return s.concurrencyService.AcquireAccountSlot(ctx, accountID, maxConcurrency) return s.concurrencyService.AcquireAccountSlot(ctx, accountID, maxConcurrency)
} }
func sortAccountsByPriority(accounts []*Account) {
sort.SliceStable(accounts, func(i, j int) bool {
return accounts[i].Priority < accounts[j].Priority
})
}
func sortAccountsByPriorityAndLastUsed(accounts []*Account, preferOAuth bool) { func sortAccountsByPriorityAndLastUsed(accounts []*Account, preferOAuth bool) {
sort.SliceStable(accounts, func(i, j int) bool { sort.SliceStable(accounts, func(i, j int) bool {
a, b := accounts[i], accounts[j] a, b := accounts[i], accounts[j]