fix(lint): 修复 goconst 和未使用导入问题
- 将重复的 "static" 字符串提取为 staticType 常量 - 移除 compression_e2e_test.go 中未使用的 fmt 导入 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
dbc74939d8
commit
74f08466d4
@ -14,6 +14,7 @@ const (
|
|||||||
gzipType = "gzip"
|
gzipType = "gzip"
|
||||||
offValue = "off"
|
offValue = "off"
|
||||||
redirectType = "redirect"
|
redirectType = "redirect"
|
||||||
|
staticType = "static"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Warning represents a conversion warning for unsupported or partially supported directives.
|
// 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:
|
case hasRootOrAlias || hasTryFiles:
|
||||||
class.LocType = "static"
|
class.LocType = staticType
|
||||||
case hasRedirect:
|
case hasRedirect:
|
||||||
class.LocType = redirectType
|
class.LocType = redirectType
|
||||||
default:
|
default:
|
||||||
// If no explicit root/alias/try_files but server-level root exists,
|
// If no explicit root/alias/try_files but server-level root exists,
|
||||||
// classify as static (will inherit server root)
|
// classify as static (will inherit server root)
|
||||||
if serverRoot != "" {
|
if serverRoot != "" {
|
||||||
class.LocType = "static"
|
class.LocType = staticType
|
||||||
} else {
|
} else {
|
||||||
class.LocType = "unsupported"
|
class.LocType = "unsupported"
|
||||||
}
|
}
|
||||||
@ -608,7 +609,7 @@ func convertLocation(class locationClassification, server *config.ServerConfig,
|
|||||||
convertProxyDirectives(class.Directives, &proxy, upstreams, result)
|
convertProxyDirectives(class.Directives, &proxy, upstreams, result)
|
||||||
server.Proxy = append(server.Proxy, proxy)
|
server.Proxy = append(server.Proxy, proxy)
|
||||||
|
|
||||||
case "static":
|
case staticType:
|
||||||
static := config.StaticConfig{
|
static := config.StaticConfig{
|
||||||
Path: class.Path,
|
Path: class.Path,
|
||||||
LocationType: locType,
|
LocationType: locType,
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user