소스 검색

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)
 }`
 )