From e4798a027cb1e3098f6dce03640d338029c8a362 Mon Sep 17 00:00:00 2001 From: Sanaei Date: Thu, 20 Aug 2026 19:37:40 +0200 Subject: [PATCH] chore(lint): adapt to staticcheck v0.8.0 under golangci-lint v2.13.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit golangci-lint v2.13.0 pinned honnef.co/go/tools v0.8.0-rc.1, whose staticcheck never terminates on internal/web/service/tgbot: the run pins ~520% CPU with RSS climbing past 700MB rather than deadlocking, so it reads as a hang. controller/, job/ and service/... only appeared stuck because they pull tgbot into the analysis graph. v2.13.1 ships the final v0.8.0 and clears it — that package goes from unbounded to 0s, and a cold full run to 22s. CI needs no pin; it already tracks latest. The same bump reworded SA1019 from parser.ParseDir to go/parser.ParseDir, which silently voided the openapigen exclusion, so the pattern now matches either spelling. fasthttp Client.RetryIf is deprecated in favour of RetryIfErr. The old path left resetTimeout at its zero value, so returning false preserves the existing retry timing exactly. The rest are gofumpt redundant-paren removals from the stricter formatter — semantic no-ops. --- .golangci.yml | 2 +- internal/util/link/outbound.go | 6 +++--- internal/web/service/tgbot/tgbot.go | 8 ++++---- internal/web/service/tgbot/tgbot_client.go | 2 +- internal/web/web.go | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3838df853..77cb580f7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -32,7 +32,7 @@ linters: # golang.org/x/tools/go/packages is a generator change, out of scope here. - linters: - staticcheck - text: "SA1019: parser.ParseDir" + text: 'SA1019: (go/)?parser\.ParseDir' # ST1005 (capitalized error strings) conflicts with intentional # user-facing error copy that tests assert verbatim. - linters: diff --git a/internal/util/link/outbound.go b/internal/util/link/outbound.go index 206967d21..697d55921 100644 --- a/internal/util/link/outbound.go +++ b/internal/util/link/outbound.go @@ -163,10 +163,10 @@ func parseVmess(link string) (*ParseResult, error) { case "grpc": svc := getString(j, "path", "") if auth, ok := j["authority"].(string); ok && auth != "" { - (stream["grpcSettings"].(map[string]any))["authority"] = auth + stream["grpcSettings"].(map[string]any)["authority"] = auth } - (stream["grpcSettings"].(map[string]any))["serviceName"] = svc - (stream["grpcSettings"].(map[string]any))["multiMode"] = getString(j, "type", "") == "multi" + stream["grpcSettings"].(map[string]any)["serviceName"] = svc + stream["grpcSettings"].(map[string]any)["multiMode"] = getString(j, "type", "") == "multi" case "httpupgrade": setHTTPUpgrade(stream, getString(j, "host", ""), getString(j, "path", "/")) case "xhttp": diff --git a/internal/web/service/tgbot/tgbot.go b/internal/web/service/tgbot/tgbot.go index 0c2493219..d7514c733 100644 --- a/internal/web/service/tgbot/tgbot.go +++ b/internal/web/service/tgbot/tgbot.go @@ -377,10 +377,10 @@ func (t *Tgbot) createRobustFastHTTPClient(proxyUrl string) *fasthttp.Client { MaxConnWaitTimeout: 10 * time.Second, DisableHeaderNamesNormalizing: false, DisablePathNormalizing: false, - // Retry on connection errors - RetryIf: func(request *fasthttp.Request) bool { - // Retry on connection errors for GET requests - return string(request.Header.Method()) == "GET" || string(request.Header.Method()) == "POST" + // resetTimeout stays false to keep the pre-RetryIfErr retry timing. + RetryIfErr: func(request *fasthttp.Request, _ int, _ error) (bool, bool) { + method := string(request.Header.Method()) + return false, method == "GET" || method == "POST" }, } diff --git a/internal/web/service/tgbot/tgbot_client.go b/internal/web/service/tgbot/tgbot_client.go index f5d3ce65d..ca9f48351 100644 --- a/internal/web/service/tgbot/tgbot_client.go +++ b/internal/web/service/tgbot/tgbot_client.go @@ -471,7 +471,7 @@ func (t *Tgbot) clientInfoMsg( if traffic.Total == 0 { total = t.I18nBot("tgbot.unlimited") } else { - total = common.FormatTraffic((traffic.Total)) + total = common.FormatTraffic(traffic.Total) } enabled := "" diff --git a/internal/web/web.go b/internal/web/web.go index 864dfb1a9..1a6898f6d 100644 --- a/internal/web/web.go +++ b/internal/web/web.go @@ -378,7 +378,7 @@ func (s *Server) startTask(restartXray bool, loc *time.Location) { // Telegram-bot–dependent jobs: periodic stats report + callback-hash cleanup. isTgbotenabled, err := s.settingService.GetTgbotEnabled() - if (err == nil) && (isTgbotenabled) { + if (err == nil) && isTgbotenabled { runtime, err := s.settingService.GetTgbotRuntime() if err != nil { logger.Warningf("Add NewStatsNotifyJob: failed to load runtime: %v; using default @daily", err) @@ -666,7 +666,7 @@ func (s *Server) start(restartXray bool, startTgBot bool) (err error) { if startTgBot { isTgbotenabled, err := s.settingService.GetTgbotEnabled() - if (err == nil) && (isTgbotenabled) { + if (err == nil) && isTgbotenabled { tgBot := s.tgbotService.NewTgbot() _ = tgBot.Start(i18nFS) // Subscribe Telegram notifications for event bus