From 74f08466d4693f446b072a86e0d6a9bc758ecce3 Mon Sep 17 00:00:00 2001 From: xfy Date: Mon, 27 Apr 2026 17:38:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(lint):=20=E4=BF=AE=E5=A4=8D=20goconst=20?= =?UTF-8?q?=E5=92=8C=E6=9C=AA=E4=BD=BF=E7=94=A8=E5=AF=BC=E5=85=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将重复的 "static" 字符串提取为 staticType 常量 - 移除 compression_e2e_test.go 中未使用的 fmt 导入 Co-Authored-By: Claude Opus 4.7 --- internal/converter/nginx/converter.go | 7 ++++--- internal/e2e/compression_e2e_test.go | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/converter/nginx/converter.go b/internal/converter/nginx/converter.go index e058641..b827ccd 100644 --- a/internal/converter/nginx/converter.go +++ b/internal/converter/nginx/converter.go @@ -14,6 +14,7 @@ const ( gzipType = "gzip" offValue = "off" redirectType = "redirect" + staticType = "static" ) // Warning represents a conversion warning for unsupported or partially supported directives. @@ -574,14 +575,14 @@ func classifyLocation(d *Directive, serverRoot string, result *ConvertResult) lo }) } case hasRootOrAlias || hasTryFiles: - class.LocType = "static" + class.LocType = staticType case hasRedirect: class.LocType = redirectType default: // If no explicit root/alias/try_files but server-level root exists, // classify as static (will inherit server root) if serverRoot != "" { - class.LocType = "static" + class.LocType = staticType } else { class.LocType = "unsupported" } @@ -608,7 +609,7 @@ func convertLocation(class locationClassification, server *config.ServerConfig, convertProxyDirectives(class.Directives, &proxy, upstreams, result) server.Proxy = append(server.Proxy, proxy) - case "static": + case staticType: static := config.StaticConfig{ Path: class.Path, LocationType: locType, diff --git a/internal/e2e/compression_e2e_test.go b/internal/e2e/compression_e2e_test.go index 3df13c7..cddbe87 100644 --- a/internal/e2e/compression_e2e_test.go +++ b/internal/e2e/compression_e2e_test.go @@ -15,7 +15,6 @@ import ( "bytes" "compress/gzip" "context" - "fmt" "io" "net/http" "os"