From 0c35f39a7ddfa34c403e633016f229089ac9e5c5 Mon Sep 17 00:00:00 2001 From: Fyn <53678344+fynxiu@users.noreply.github.com> Date: Fri, 4 Mar 2022 15:36:20 +0800 Subject: [PATCH] fix: fix(gctl): apiparser_parser auto format (#1607) --- tools/goctl/api/parser/g4/gen/api/apiparser_parser.go | 3 --- tools/goctl/api/parser/g4/gen/api/file_splitor_test.go | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go b/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go index 9b602a9f..8599337c 100755 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go @@ -634,6 +634,3 @@ func NewSyntaxLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, in return p } - - - diff --git a/tools/goctl/api/parser/g4/gen/api/file_splitor_test.go b/tools/goctl/api/parser/g4/gen/api/file_splitor_test.go index ab7f0682..541d6cbe 100644 --- a/tools/goctl/api/parser/g4/gen/api/file_splitor_test.go +++ b/tools/goctl/api/parser/g4/gen/api/file_splitor_test.go @@ -8,6 +8,7 @@ import ( "bufio" "bytes" "fmt" + "go/format" "io/ioutil" "log" "os" @@ -61,7 +62,12 @@ import "github.com/zeromicro/antlr" } } - err = ioutil.WriteFile(fp, buffer.Bytes(), os.ModePerm) + src, err := format.Source(buffer.Bytes()) + if err != nil { + fmt.Printf("%+v\n", err) + break + } + err = ioutil.WriteFile(fp, src, os.ModePerm) if err != nil { fmt.Printf("%+v\n", err) }