ソースを参照

no \t to space line (#3177)

Co-authored-by: chenjieping <chenjieping@kezaihui.com>
chensy 2 年 前
コミット
c0f8a58ed7
2 ファイル変更13 行追加1 行削除
  1. 3 1
      tools/goctl/api/format/format.go
  2. 10 0
      tools/goctl/api/format/format_test.go

+ 3 - 1
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++

+ 10 - 0
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)
 }`
 )