chore: upgrade Go version to 1.24 and update dependencies (#5499)

This commit is contained in:
Kevin Wan
2026-03-22 18:47:43 +08:00
committed by GitHub
parent 9a6447ab5c
commit ba9c275853
15 changed files with 290 additions and 231 deletions

View File

@@ -197,7 +197,7 @@ func (p *printer) print(x reflect.Value) {
case reflect.Struct:
if val, ok := x.Interface().(apitoken.Position); ok {
p.printf(val.String())
p.printf("%s", val.String())
return
}
t := x.Type()

View File

@@ -357,7 +357,7 @@ func (w *Writer) Write(opts ...Option) {
// WriteText writes the text.
func (w *Writer) WriteText(text string) {
_, _ = fmt.Fprintf(w.tw, text)
_, _ = fmt.Fprint(w.tw, text)
}
func (w *Writer) write(opt *option) {

View File

@@ -284,7 +284,7 @@ func (api *API) parseImportedAPI(imports []ast.ImportStmt) ([]*API, error) {
}
// import cycle check
if err := api.importManager.Push(impPath); err != nil {
return nil, ast.SyntaxError(tok.Position, err.Error())
return nil, ast.SyntaxError(tok.Position, "%s", err.Error())
}
if _, ok := api.importSet[impPath]; ok {

View File

@@ -1,7 +1,7 @@
package parser
import (
"fmt"
"errors"
"strings"
)
@@ -24,5 +24,5 @@ func (e *errorManager) error() error {
if len(e.errors) == 0 {
return nil
}
return fmt.Errorf(strings.Join(e.errors, "\n"))
return errors.New(strings.Join(e.errors, "\n"))
}

View File

@@ -1676,7 +1676,7 @@ func (p *Parser) CheckErrors() error {
errors = append(errors, e.Error())
}
return fmt.Errorf(strings.Join(errors, "\n"))
return fmt.Errorf("%s", strings.Join(errors, "\n"))
}
func (p *Parser) appendStmt(stmt ...ast.Stmt) {

View File

@@ -130,7 +130,7 @@ func TestParser_Parse_infoStmt(t *testing.T) {
"author": `"type author here"`,
"email": `"type email here"`,
"version": `"type version here"`,
"enable": `true`,
"enable": `true`,
"disable": `false`,
}
p := New("foo.api", infoTestAPI)
@@ -762,6 +762,11 @@ func TestParser_Parse_service(t *testing.T) {
}),
},
Request: &ast.BodyStmt{
LParen: ast.NewTokenNode(token.Token{Type: token.LPAREN, Text: "("}),
RParen: ast.NewTokenNode(token.Token{Type: token.RPAREN, Text: ")"}),
},
Returns: ast.NewTokenNode(token.Token{Type: token.IDENT, Text: "returns"}),
Response: &ast.BodyStmt{
LParen: ast.NewTokenNode(token.Token{Type: token.LPAREN, Text: "("}),
Body: &ast.BodyExpr{
Value: ast.NewTokenNode(token.Token{Type: token.IDENT, Text: "Foo"}),