From 48c0bb1e970a9a76d5e3179e57dc295155dcf341 Mon Sep 17 00:00:00 2001 From: lc6464 <64722907+lc6464@users.noreply.github.com> Date: Wed, 1 Apr 2026 00:15:29 +0800 Subject: [PATCH] fix(lint): resolve gci and predeclared issues in model probe --- web/backend/api/model_status.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/web/backend/api/model_status.go b/web/backend/api/model_status.go index c7cae10d9..379d4e937 100644 --- a/web/backend/api/model_status.go +++ b/web/backend/api/model_status.go @@ -11,9 +11,10 @@ import ( "sync" "time" + "golang.org/x/sync/singleflight" + "github.com/sipeed/picoclaw/pkg/config" "github.com/sipeed/picoclaw/pkg/providers" - "golang.org/x/sync/singleflight" ) const ( @@ -308,7 +309,7 @@ func (s *modelProbeCacheState) gc(now time.Time, runTTL bool) { } effectiveLen := cacheLen - len(expiredKeys) - removeCount := max(effectiveLen - modelProbeCacheTrimToEntries, 0) + removeCount := max(effectiveLen-modelProbeCacheTrimToEntries, 0) candidates := make([]evictionCandidate, 0) if removeCount > 0 { @@ -360,7 +361,7 @@ func (s *modelProbeCacheState) gc(now time.Time, runTTL bool) { } } -func modelProbeBackoffDelay(base, max time.Duration, streak int) time.Duration { +func modelProbeBackoffDelay(base, maxDelay time.Duration, streak int) time.Duration { if streak <= 0 { streak = 1 } @@ -368,8 +369,8 @@ func modelProbeBackoffDelay(base, max time.Duration, streak int) time.Duration { shift := min(streak-1, modelProbeBackoffMaxShift) delay := base * time.Duration(1< 0 && (delay > max || delay < 0) { - return max + if maxDelay > 0 && (delay > maxDelay || delay < 0) { + return maxDelay } if delay <= 0 { return base