Skip to content

Commit 7f0d0bc

Browse files
authored
Fix comment issue (#136)
* README: update isolated comment blocks Signed-off-by: Loong <[email protected]> * fix the top comment Signed-off-by: Loong <[email protected]> --------- Signed-off-by: Loong <[email protected]>
1 parent 33a14c3 commit 7f0d0bc

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

README.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,20 @@ GCI considers a import block based on AST as below:
99
Doc
1010
Name Path Comment
1111
```
12-
All comments will keep as they were, except the independent comment blocks(line breaks before and after).
12+
All comments will keep as they were, except the isolated comment blocks.
13+
14+
The isolated comment blocks like below:
15+
```
16+
import (
17+
"fmt"
18+
// this line is isolated comment
19+
20+
// those lines belong to one
21+
// isolated comment blocks
22+
23+
"github.com/daixiang0/gci"
24+
)
25+
```
1326

1427
GCI splits all import blocks into different sections, now support five section type:
1528
- standard: Golang official imports, like "fmt"

pkg/gci/gci.go

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ func LoadFormatGoFile(file io.FileObj, cfg config.Config) (src, dist []byte, err
170170

171171
// add beginning of import block
172172
head = append(head, `import (`...)
173+
head = append(head, utils.Linebreak)
173174
// add end of import block
174175
body = append(body, []byte{utils.RightParenthesis, utils.Linebreak}...)
175176

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
common.cfg.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import (
4+
"os" // https://pkg.go.dev/os
5+
// https://pkg.go.dev/fmt
6+
"fmt"
7+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import (
4+
// https://pkg.go.dev/fmt
5+
"fmt"
6+
"os" // https://pkg.go.dev/os
7+
)

0 commit comments

Comments
 (0)