diff options
Diffstat (limited to 'build/codeformat')
-rw-r--r-- | build/codeformat/formatimports.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/build/codeformat/formatimports.go b/build/codeformat/formatimports.go index c6427f6a99..fedc5cc090 100644 --- a/build/codeformat/formatimports.go +++ b/build/codeformat/formatimports.go @@ -20,8 +20,10 @@ var importPackageGroupOrders = map[string]int{ var errInvalidCommentBetweenImports = errors.New("comments between imported packages are invalid, please move comments to the end of the package line") -var importBlockBegin = []byte("\nimport (\n") -var importBlockEnd = []byte("\n)") +var ( + importBlockBegin = []byte("\nimport (\n") + importBlockEnd = []byte("\n)") +) type importLineParsed struct { group string @@ -59,8 +61,10 @@ func parseImportLine(line string) (*importLineParsed, error) { return il, nil } -type importLineGroup []*importLineParsed -type importLineGroupMap map[string]importLineGroup +type ( + importLineGroup []*importLineParsed + importLineGroupMap map[string]importLineGroup +) func formatGoImports(contentBytes []byte) ([]byte, error) { p1 := bytes.Index(contentBytes, importBlockBegin) @@ -153,7 +157,7 @@ func formatGoImports(contentBytes []byte) ([]byte, error) { return formattedBytes, nil } -//FormatGoImports format the imports by our rules (see unit tests) +// FormatGoImports format the imports by our rules (see unit tests) func FormatGoImports(file string) error { f, err := os.Open(file) if err != nil { @@ -177,7 +181,7 @@ func FormatGoImports(file string) error { if bytes.Equal(contentBytes, formattedBytes) { return nil } - f, err = os.OpenFile(file, os.O_TRUNC|os.O_WRONLY, 0644) + f, err = os.OpenFile(file, os.O_TRUNC|os.O_WRONLY, 0o644) if err != nil { return err } |