From 8813c25079ca5d0e04636c1906c8519b4a438a0c Mon Sep 17 00:00:00 2001 From: Loong Dai Date: Wed, 13 Jul 2022 10:28:30 +0800 Subject: [PATCH] fix extra linkbreak in the end Signed-off-by: Loong Dai --- pkg/gci/gci.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/gci/gci.go b/pkg/gci/gci.go index 170c03f..945c1ba 100644 --- a/pkg/gci/gci.go +++ b/pkg/gci/gci.go @@ -180,7 +180,9 @@ func LoadFormatGoFile(file io.FileObj, cfg config.Config) (src, dist []byte, err AddIndent(&body, &firstWithIndex) body = append(body, src[d.Start:d.End]...) } - body = append(body, utils.Linebreak) + if body[len(body)-1] != utils.Linebreak { + body = append(body, utils.Linebreak) + } } // remove breakline in the end