You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-6
Original file line number
Diff line number
Diff line change
@@ -34,9 +34,10 @@ GCI splits all import blocks into different sections, now support five section t
34
34
- default: All rest import blocks
35
35
- blank: Put blank imports together in a separate group
36
36
- dot: Put dot imports together in a separate group
37
+
- alias: Put alias imports together in a separate group
37
38
38
-
The priority is standard > default > custom > blank > dot, all sections sort alphabetically inside.
39
-
By default, blank and dot sections are not used and the corresponding lines end up in the other groups.
39
+
The priority is standard > default > custom > blank > dot > alias, all sections sort alphabetically inside.
40
+
By default, blank , dot and alias sections are not used and the corresponding lines end up in the other groups.
40
41
41
42
All import blocks use one TAB(`\t`) as Indent.
42
43
@@ -88,12 +89,13 @@ Flags:
88
89
--custom-order Enable custom order of sections
89
90
-d, --debug Enables debug output from the formatter
90
91
-h, --help helpfor print
91
-
-s, --section stringArray Sections define how inputs will be processed. Section names are case-insensitive and may contain parameters in (). The section order is standard > default > custom > blank > dot. The default value is [standard,default].
92
+
-s, --section stringArray Sections define how inputs will be processed. Section names are case-insensitive and may contain parameters in (). The section order is standard > default > custom > blank > dot> alias. The default value is [standard,default].
92
93
standard - standard section that Go provides officially, like "fmt"
93
94
Prefix(github.com/daixiang0) - custom section, groups all imports with the specified Prefix. Imports will be matched to the longest Prefix. Multiple custom prefixes may be provided, they will be rendered as distinct sections separated by newline. You can regroup multiple prefixes by separating them with comma: Prefix(github.com/daixiang0,gitlab.com/daixiang0,daixiang0)
94
95
default - default section, contains all rest imports
95
96
blank - blank section, contains all blank imports.
96
97
dot - dot section, contains all dot imports. (default [standard,default])
98
+
alias - alias section, contains all alias imports.
97
99
--skip-generated Skip generated files
98
100
--skip-vendor Skip files inside vendor directory
99
101
```
@@ -112,12 +114,13 @@ Flags:
112
114
--custom-order Enable custom order of sections
113
115
-d, --debug Enables debug output from the formatter
114
116
-h, --help helpfor write
115
-
-s, --section stringArray Sections define how inputs will be processed. Section names are case-insensitive and may contain parameters in (). The section order is standard > default > custom > blank > dot. The default value is [standard,default].
117
+
-s, --section stringArray Sections define how inputs will be processed. Section names are case-insensitive and may contain parameters in (). The section order is standard > default > custom > blank > dot> alias. The default value is [standard,default].
116
118
standard - standard section that Go provides officially, like "fmt"
117
119
Prefix(github.com/daixiang0) - custom section, groups all imports with the specified Prefix. Imports will be matched to the longest Prefix. Multiple custom prefixes may be provided, they will be rendered as distinct sections separated by newline. You can regroup multiple prefixes by separating them with comma: Prefix(github.com/daixiang0,gitlab.com/daixiang0,daixiang0)
118
120
default - default section, contains all rest imports
119
121
blank - blank section, contains all blank imports.
120
122
dot - dot section, contains all dot imports. (default [standard,default])
123
+
alias - alias section, contains all alias imports.
121
124
--skip-generated Skip generated files
122
125
--skip-vendor Skip files inside vendor directory
123
126
```
@@ -133,11 +136,12 @@ Flags:
133
136
--custom-order Enable custom order of sections
134
137
-d, --debug Enables debug output from the formatter
135
138
-h, --help helpfor list
136
-
-s, --section stringArray Sections define how inputs will be processed. Section names are case-insensitive and may contain parameters in (). The section order is standard > default > custom > blank > dot. The default value is [standard,default].
139
+
-s, --section stringArray Sections define how inputs will be processed. Section names are case-insensitive and may contain parameters in (). The section order is standard > default > custom > blank > dot> alias. The default value is [standard,default].
137
140
standard - standard section that Go provides officially, like "fmt"
138
141
Prefix(github.com/daixiang0) - custom section, groups all imports with the specified Prefix. Imports will be matched to the longest Prefix. Multiple custom prefixes may be provided, they will be rendered as distinct sections separated by newline. You can regroup multiple prefixes by separating them with comma: Prefix(github.com/daixiang0,gitlab.com/daixiang0,daixiang0)
139
142
default - default section, contains all rest imports
140
143
blank - blank section, contains all blank imports.
144
+
alias - alias section, contains all alias imports.
141
145
dot - dot section, contains all dot imports. (default [standard,default])
142
146
--skip-generated Skip generated files
143
147
--skip-vendor Skip files inside vendor directory
@@ -154,11 +158,12 @@ Flags:
154
158
--custom-order Enable custom order of sections
155
159
-d, --debug Enables debug output from the formatter
156
160
-h, --help helpfor diff
157
-
-s, --section stringArray Sections define how inputs will be processed. Section names are case-insensitive and may contain parameters in (). The section order is standard > default > custom > blank > dot. The default value is [standard,default].
161
+
-s, --section stringArray Sections define how inputs will be processed. Section names are case-insensitive and may contain parameters in (). The section order is standard > default > custom > blank > dot> alias. The default value is [standard,default].
158
162
standard - standard section that Go provides officially, like "fmt"
159
163
Prefix(github.com/daixiang0) - custom section, groups all imports with the specified Prefix. Imports will be matched to the longest Prefix. Multiple custom prefixes may be provided, they will be rendered as distinct sections separated by newline. You can regroup multiple prefixes by separating them with comma: Prefix(github.com/daixiang0,gitlab.com/daixiang0,daixiang0)
160
164
default - default section, contains all rest imports
161
165
blank - blank section, contains all blank imports.
166
+
alias - alias section, contains all alias imports.
162
167
dot - dot section, contains all dot imports. (default [standard,default])
163
168
--skip-generated Skip generated files
164
169
--skip-vendor Skip files inside vendor directory
@@ -284,6 +289,38 @@ import (
284
289
)
285
290
```
286
291
292
+
### with alias grouping enabled
293
+
294
+
```go
295
+
package main
296
+
297
+
import (
298
+
testing "github.com/daixiang0/test"
299
+
"fmt"
300
+
301
+
g "github.com/golang"
302
+
303
+
"github.com/daixiang0/gci"
304
+
"github.com/daixiang0/gci/subtest"
305
+
)
306
+
```
307
+
308
+
to
309
+
310
+
```go
311
+
package main
312
+
313
+
import (
314
+
"fmt"
315
+
316
+
"github.com/daixiang0/gci"
317
+
"github.com/daixiang0/gci/subtest"
318
+
319
+
testing "github.com/daixiang0/test"
320
+
g "github.com/golang"
321
+
)
322
+
```
323
+
287
324
## TODO
288
325
289
326
- Ensure only one blank between `Name` and `Path`in an import block
Copy file name to clipboardExpand all lines: cmd/gci/gcicommand.go
+3-2
Original file line number
Diff line number
Diff line change
@@ -48,12 +48,13 @@ func (e *Executor) newGciCommand(use, short, long string, aliases []string, stdI
48
48
49
49
debug=cmd.Flags().BoolP("debug", "d", false, "Enables debug output from the formatter")
50
50
51
-
sectionHelp:=`Sections define how inputs will be processed. Section names are case-insensitive and may contain parameters in (). The section order is standard > default > custom > blank > dot. The default value is [standard,default].
51
+
sectionHelp:=`Sections define how inputs will be processed. Section names are case-insensitive and may contain parameters in (). The section order is standard > default > custom > blank > dot > alias. The default value is [standard,default].
52
52
standard - standard section that Go provides officially, like "fmt"
53
53
Prefix(github.com/daixiang0) - custom section, groups all imports with the specified Prefix. Imports will be matched to the longest Prefix. Multiple custom prefixes may be provided, they will be rendered as distinct sections separated by newline. You can regroup multiple prefixes by separating them with comma: Prefix(github.com/daixiang0,gitlab.com/daixiang0,daixiang0)
54
54
default - default section, contains all rest imports
55
55
blank - blank section, contains all blank imports.
56
-
dot - dot section, contains all dot imports.`
56
+
dot - dot section, contains all dot imports.
57
+
alias - alias section, contains all alias imports.`
0 commit comments