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: cmd/goimports/goimports.go
+11-4
Original file line number
Diff line number
Diff line change
@@ -26,10 +26,11 @@ import (
26
26
27
27
var (
28
28
// main operation modes
29
-
list=flag.Bool("l", false, "list files whose formatting differs from goimport's")
30
-
write=flag.Bool("w", false, "write result to (source) file instead of stdout")
31
-
doDiff=flag.Bool("d", false, "display diffs instead of rewriting files")
32
-
srcdir=flag.String("srcdir", "", "choose imports as if source code is from `dir`. When operating on a single file, dir may instead be the complete file name.")
29
+
list=flag.Bool("l", false, "list files whose formatting differs from goimport's")
30
+
write=flag.Bool("w", false, "write result to (source) file instead of stdout")
31
+
doDiff=flag.Bool("d", false, "display diffs instead of rewriting files")
32
+
srcdir=flag.String("srcdir", "", "choose imports as if source code is from `dir`. When operating on a single file, dir may instead be the complete file name.")
33
+
diffExitCode=flag.Bool("exit-code", false, "exit with a non-zero exit code if files were not already formatted") // use in ci lint
33
34
34
35
verbosebool// verbose logging
35
36
@@ -53,6 +54,7 @@ func init() {
53
54
flag.BoolVar(&options.AllErrors, "e", false, "report all errors (not just the first 10 on different lines)")
54
55
flag.StringVar(&options.LocalPrefix, "local", "", "put imports beginning with this string after 3rd-party packages; comma-separated list")
55
56
flag.BoolVar(&options.FormatOnly, "format-only", false, "if true, don't fix imports and only format. In this mode, goimports is effectively gofmt, with the addition that imports are grouped into sections.")
57
+
flag.BoolVar(&options.RegroupImports, "r", false, "remove blank line in imports")
56
58
}
57
59
58
60
funcreport(errerror) {
@@ -144,6 +146,11 @@ func processFile(filename string, in io.Reader, out io.Writer, argType argumentT
0 commit comments