From 49e99e9d519a55cbe6d3bd94b810978dd64ce4b8 Mon Sep 17 00:00:00 2001 From: haruka <1628615876@qq.com> Date: Mon, 30 Mar 2026 16:44:15 +0800 Subject: [PATCH] fix: resolve errcheck lint for sync.Map type assertion Co-Authored-By: Claude Opus 4.6 (1M context) --- backend/internal/service/oauth_refresh_api.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/internal/service/oauth_refresh_api.go b/backend/internal/service/oauth_refresh_api.go index fdc0ce40..571e9ecd 100644 --- a/backend/internal/service/oauth_refresh_api.go +++ b/backend/internal/service/oauth_refresh_api.go @@ -54,8 +54,13 @@ func NewOAuthRefreshAPI(accountRepo AccountRepository, tokenCache GeminiTokenCac // getLocalLock 返回指定 cacheKey 的进程内互斥锁 func (api *OAuthRefreshAPI) getLocalLock(cacheKey string) *sync.Mutex { - val, _ := api.localLocks.LoadOrStore(cacheKey, &sync.Mutex{}) - return val.(*sync.Mutex) + actual, _ := api.localLocks.LoadOrStore(cacheKey, &sync.Mutex{}) + mu, ok := actual.(*sync.Mutex) + if !ok { + mu = &sync.Mutex{} + api.localLocks.Store(cacheKey, mu) + } + return mu } // RefreshIfNeeded 在分布式锁保护下按需刷新 OAuth token