From c0f8a58ed7c9a96f31e7acf240d22a3761652719 Mon Sep 17 00:00:00 2001 From: chensy <1278651995@qq.com> Date: Sat, 29 Apr 2023 16:35:04 +0800 Subject: [PATCH] no \t to space line (#3177) Co-authored-by: chenjieping --- tools/goctl/api/format/format.go | 4 +++- tools/goctl/api/format/format_test.go | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/goctl/api/format/format.go b/tools/goctl/api/format/format.go index ad9f91e4..afa7ee6a 100644 --- a/tools/goctl/api/format/format.go +++ b/tools/goctl/api/format/format.go @@ -171,7 +171,9 @@ func apiFormat(data string, skipCheckDeclare bool, filename ...string) (string, tapCount++ } } - util.WriteIndent(&builder, tapCount) + if line != "" { + util.WriteIndent(&builder, tapCount) + } builder.WriteString(line + pathx.NL) if strings.HasSuffix(noCommentLine, leftParenthesis) || strings.HasSuffix(noCommentLine, leftBrace) { tapCount++ diff --git a/tools/goctl/api/format/format_test.go b/tools/goctl/api/format/format_test.go index 076b25a8..786ac42b 100644 --- a/tools/goctl/api/format/format_test.go +++ b/tools/goctl/api/format/format_test.go @@ -26,6 +26,11 @@ service A-api { handler: GreetHandler ) get /greet/from/:name(Request) returns (Response) + +@server( +handler: GreetHandler2 + ) + get /greet/from2/:name(Request) returns (Response) } ` @@ -41,6 +46,11 @@ service A-api { handler: GreetHandler ) get /greet/from/:name(Request) returns (Response) + + @server( + handler: GreetHandler2 + ) + get /greet/from2/:name(Request) returns (Response) }` )