-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add flag for skipping files inside vendor directory (#139)
Signed-off-by: Artur Rychlewicz <[email protected]>
- Loading branch information
Showing
8 changed files
with
105 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ The isolated comment blocks like below: | |
|
||
``` | ||
import ( | ||
"fmt" | ||
"fmt" | ||
// this line is isolated comment | ||
// those lines belong to one | ||
|
@@ -28,6 +28,7 @@ import ( | |
``` | ||
|
||
GCI splits all import blocks into different sections, now support five section type: | ||
|
||
- standard: Go official imports, like "fmt" | ||
- custom: Custom section, use full and the longest match (match full string first, if multiple matches, use the longest one) | ||
- default: All rest import blocks | ||
|
@@ -64,14 +65,14 @@ go install github.com/daixiang0/[email protected] | |
Now GCI provides two command line methods, mainly for backward compatibility. | ||
|
||
### New style | ||
|
||
GCI supports three modes of operation | ||
|
||
> **Note** | ||
> | ||
> Since v0.10.0, the `-s` and `--section` flag can only be used multiple times to specify multiple sections. | ||
> For example, you could use `-s standard,default` before, but now you must use `-s standard -s default`. | ||
> This breaking change makes it possible for the project to support specifying multiple custom prefixes. (Please see below.) | ||
> | ||
> Since v0.10.0, the `-s` and `--section` flag can only be used multiple times to specify multiple sections. | ||
> For example, you could use `-s standard,default` before, but now you must use `-s standard -s default`. | ||
> This breaking change makes it possible for the project to support specifying multiple custom prefixes. (Please see below.) | ||
```shell | ||
$ gci print -h | ||
|
@@ -84,15 +85,17 @@ Aliases: | |
print, output | ||
|
||
Flags: | ||
-d, --debug Enables debug output from the formatter | ||
-h, --help help for write | ||
-s, --section strings 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]. | ||
standard - standard section that Go provides officially, like "fmt" | ||
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) | ||
default - default section, contains all rest imports | ||
blank - blank section, contains all blank imports. | ||
--skip-generated Skip generated files | ||
--custom-order Enable custom order of sections. If specified, make the section order the same as your configuration order. The default order is standard > default > custom > blank > dot. | ||
--custom-order Enable custom order of sections | ||
-d, --debug Enables debug output from the formatter | ||
-h, --help help for print | ||
-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]. | ||
standard - standard section that Go provides officially, like "fmt" | ||
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) | ||
default - default section, contains all rest imports | ||
blank - blank section, contains all blank imports. | ||
dot - dot section, contains all dot imports. (default [standard,default]) | ||
--skip-generated Skip generated files | ||
--skip-vendor Skip files inside vendor directory | ||
``` | ||
|
||
```shell | ||
|
@@ -106,19 +109,19 @@ Aliases: | |
write, overwrite | ||
|
||
Flags: | ||
-d, --debug Enables debug output from the formatter | ||
-h, --help help for write | ||
-s, --section strings 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]. | ||
standard - standard section that Go provides officially, like "fmt" | ||
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) | ||
default - default section, contains all rest imports | ||
blank - blank section, contains all blank imports. | ||
dot - dot section, contains all dot imports. | ||
--skip-generated Skip generated files | ||
--custom-order Enable custom order of sections. If specified, make the section order the same as your configuration order. The default order is standard > default > custom > blank > dot. | ||
--custom-order Enable custom order of sections | ||
-d, --debug Enables debug output from the formatter | ||
-h, --help help for write | ||
-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]. | ||
standard - standard section that Go provides officially, like "fmt" | ||
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) | ||
default - default section, contains all rest imports | ||
blank - blank section, contains all blank imports. | ||
dot - dot section, contains all dot imports. (default [standard,default]) | ||
--skip-generated Skip generated files | ||
--skip-vendor Skip files inside vendor directory | ||
``` | ||
|
||
|
||
```shell | ||
$ gci list -h | ||
Prints the filenames that need to be formatted. If you want to show the diff use diff instead, and if you want to apply the changes use write instead | ||
|
@@ -137,6 +140,7 @@ Flags: | |
blank - blank section, contains all blank imports. | ||
dot - dot section, contains all dot imports. (default [standard,default]) | ||
--skip-generated Skip generated files | ||
--skip-vendor Skip files inside vendor directory | ||
``` | ||
```shell | ||
|
@@ -147,23 +151,36 @@ Usage: | |
gci diff path... [flags] | ||
|
||
Flags: | ||
-d, --debug Enables debug output from the formatter | ||
-h, --help help for write | ||
-s, --section strings 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]. | ||
standard - standard section that Go provides officially, like "fmt" | ||
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) | ||
default - default section, contains all rest imports | ||
blank - blank section, contains all blank imports. | ||
dot - dot section, contains all dot imports. | ||
--skip-generated Skip generated files | ||
--custom-order Enable custom order of sections. If specified, make the section order the same as your configuration order. The default order is standard > default > custom > blank > dot. | ||
--custom-order Enable custom order of sections | ||
-d, --debug Enables debug output from the formatter | ||
-h, --help help for diff | ||
-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]. | ||
standard - standard section that Go provides officially, like "fmt" | ||
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) | ||
default - default section, contains all rest imports | ||
blank - blank section, contains all blank imports. | ||
dot - dot section, contains all dot imports. (default [standard,default]) | ||
--skip-generated Skip generated files | ||
--skip-vendor Skip files inside vendor directory | ||
``` | ||
### Old style | ||
```shell | ||
Gci enables automatic formatting of imports in a deterministic manner | ||
If you want to integrate this as part of your CI take a look at golangci-lint. | ||
|
||
Usage: | ||
gci [-diff | -write] [--local localPackageURLs] path... [flags] | ||
gci [command] | ||
|
||
Available Commands: | ||
completion Generate the autocompletion script for the specified shell | ||
diff Prints a git style diff to STDOUT | ||
help Help about any command | ||
list Prints filenames that need to be formatted to STDOUT | ||
print Outputs the formatted file to STDOUT | ||
write Formats the specified files in-place | ||
|
||
Flags: | ||
-d, --diff display diffs instead of rewriting files | ||
|
@@ -172,6 +189,7 @@ Flags: | |
-v, --version version for gci | ||
-w, --write write result to (source) file instead of stdout | ||
|
||
Use "gci [command] --help" for more information about a command. | ||
``` | ||
**Note**:: | ||
|
@@ -188,9 +206,9 @@ Run `gci write -s standard -s default -s "prefix(github.com/daixiang0/gci)" main | |
package main | ||
import ( | ||
"golang.org/x/tools" | ||
|
||
"fmt" | ||
|
||
"github.com/daixiang0/gci" | ||
) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters