From 34bbfb5dd2059f57049fbce72bec5645171d1262 Mon Sep 17 00:00:00 2001 From: IanShaw027 <131567472+IanShaw027@users.noreply.github.com> Date: Thu, 1 Jan 2026 14:07:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(lint):=20=E4=BF=AE=E5=A4=8D=20golangci-lint?= =?UTF-8?q?=20=E6=A3=80=E6=9F=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复未检查的错误返回值 (errcheck) - 移除未使用的 httpClient 字段 (unused) - 修复低效赋值问题 (ineffassign) - 使用 switch 替代 if-else 链 (staticcheck QF1003) - 修复错误字符串首字母大写问题 (staticcheck ST1005) - 运行 gofmt 格式化代码 --- .../internal/handler/admin/account_handler.go | 12 ++++++---- .../internal/pkg/geminicli/drive_client.go | 22 +++++++------------ .../internal/service/gemini_oauth_service.go | 20 +++++++++-------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/backend/internal/handler/admin/account_handler.go b/backend/internal/handler/admin/account_handler.go index 58715706..78b71431 100644 --- a/backend/internal/handler/admin/account_handler.go +++ b/backend/internal/handler/admin/account_handler.go @@ -1023,6 +1023,10 @@ func (h *AccountHandler) RefreshTier(c *gin.Context) { } tierID, storageInfo, err := h.geminiOAuthService.FetchGoogleOneTier(c.Request.Context(), accessToken, proxyURL) + if err != nil { + response.ErrorFrom(c, err) + return + } if account.Extra == nil { account.Extra = make(map[string]any) @@ -1044,10 +1048,10 @@ func (h *AccountHandler) RefreshTier(c *gin.Context) { } response.Success(c, gin.H{ - "tier_id": tierID, - "drive_storage_limit": account.Extra["drive_storage_limit"], - "drive_storage_usage": account.Extra["drive_storage_usage"], - "updated_at": account.Extra["drive_tier_updated_at"], + "tier_id": tierID, + "drive_storage_limit": account.Extra["drive_storage_limit"], + "drive_storage_usage": account.Extra["drive_storage_usage"], + "updated_at": account.Extra["drive_tier_updated_at"], }) } diff --git a/backend/internal/pkg/geminicli/drive_client.go b/backend/internal/pkg/geminicli/drive_client.go index 5a959fac..79d6835f 100644 --- a/backend/internal/pkg/geminicli/drive_client.go +++ b/backend/internal/pkg/geminicli/drive_client.go @@ -22,17 +22,11 @@ type DriveClient interface { GetStorageQuota(ctx context.Context, accessToken, proxyURL string) (*DriveStorageInfo, error) } -type driveClient struct { - httpClient *http.Client -} +type driveClient struct{} // NewDriveClient creates a new Drive API client func NewDriveClient() DriveClient { - return &driveClient{ - httpClient: &http.Client{ - Timeout: 10 * time.Second, - }, - } + return &driveClient{} } // GetStorageQuota fetches storage quota from Google Drive API @@ -71,7 +65,7 @@ func (c *driveClient) GetStorageQuota(ctx context.Context, accessToken, proxyURL // Rate limit - retry with exponential backoff if resp.StatusCode == http.StatusTooManyRequests && attempt < maxRetries-1 { - resp.Body.Close() + _ = resp.Body.Close() backoff := time.Duration(1< 24 hours) needsRefresh := true if account.Extra != nil {