2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 06:47:20 +08:00

fix: lint

This commit is contained in:
2025-12-01 16:29:37 +08:00
parent bd453daed9
commit 027eb73ab4
7 changed files with 14 additions and 27 deletions

View File

@@ -82,14 +82,6 @@ func (l *Lexer) readChar() {
}
}
// peekChar 预览下一个字符而不移动位置
func (l *Lexer) peekChar() rune {
if l.pos+1 >= len(l.buf) {
return 0
}
return l.buf[l.pos+1]
}
// skipWhitespace 跳过空白字符
func (l *Lexer) skipWhitespace() {
for l.current == ' ' || l.current == '\t' || l.current == '\r' {

View File

@@ -404,17 +404,16 @@ func (p *Parser) parseBlockDirective(token Token) (*Block, error) {
break
}
if nextToken.Type == NEWLINE {
switch nextToken.Type {
case NEWLINE:
continue
}
if nextToken.Type == DIRECTIVE {
case DIRECTIVE:
directive, err := p.parseDirective(nextToken)
if err != nil {
return nil, err
}
block.Directives = append(block.Directives, directive)
} else if nextToken.Type == COMMENT {
case COMMENT:
// 处理块内注释
comment := &Comment{
Text: nextToken.Value,
@@ -422,6 +421,8 @@ func (p *Parser) parseBlockDirective(token Token) (*Block, error) {
Column: nextToken.Column,
}
block.Comments = append(block.Comments, comment)
default:
continue
}
}

View File

@@ -78,9 +78,7 @@ func parseProxyFile(filePath string) (*types.Proxy, error) {
}
// 解析 ProxyPreserveHost
if regexp.MustCompile(`ProxyPreserveHost\s+On`).MatchString(contentStr) {
// Host 由客户端提供
}
_ = regexp.MustCompile(`ProxyPreserveHost\s+On`).MatchString(contentStr)
// 解析 RequestHeader set Host
hostPattern := regexp.MustCompile(`RequestHeader\s+set\s+Host\s+"([^"]+)"`)

View File

@@ -546,7 +546,7 @@ func (v *baseVhost) BasicAuth() map[string]string {
}
func (v *baseVhost) SetBasicAuth(auth map[string]string) error {
if auth == nil || len(auth) == 0 {
if len(auth) == 0 {
// 清除基本认证配置
v.vhost.RemoveDirective("AuthType")
v.vhost.RemoveDirective("AuthName")

View File

@@ -45,9 +45,9 @@ func (s *VhostTestSuite) TearDownTest() {
}
func (s *VhostTestSuite) TestNewVhost() {
s.Equal(s.configDir, s.vhost.baseVhost.configDir)
s.NotNil(s.vhost.baseVhost.config)
s.NotNil(s.vhost.baseVhost.vhost)
s.Equal(s.configDir, s.vhost.configDir)
s.NotNil(s.vhost.config)
s.NotNil(s.vhost.vhost)
}
func (s *VhostTestSuite) TestEnable() {

View File

@@ -493,9 +493,7 @@ func (p *Parser) SetErrorLog(errorLog string) error {
// SetReturn 设置 return 指令(用于禁用网站)
func (p *Parser) SetReturn(code, url string) error {
if err := p.Clear("server.return"); err != nil {
// 忽略不存在的错误
}
_ = p.Clear("server.return") // 忽略不存在的错误
directives := []*config.Directive{
{
@@ -534,9 +532,7 @@ func (p *Parser) SetReturn(code, url string) error {
// SetLimitRate 设置限速配置
func (p *Parser) SetLimitRate(limitRate string) error {
if err := p.Clear("server.limit_rate"); err != nil {
// 忽略不存在的错误
}
_ = p.Clear("server.limit_rate") // 忽略不存在的错误
if limitRate == "" {
return nil // 清除限速配置

View File

@@ -451,7 +451,7 @@ func (v *baseVhost) BasicAuth() map[string]string {
}
func (v *baseVhost) SetBasicAuth(auth map[string]string) error {
if auth == nil || len(auth) == 0 {
if len(auth) == 0 {
// 清除基本认证配置
return v.parser.SetBasicAuth("", "")
}