From 54e9ee37a7a301dbe74d46fd3c87712e6120e9bf Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 20 Jan 2022 18:46:10 +0100 Subject: format with gofumpt (#18184) * gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt --- build/codeformat/formatimports.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'build/codeformat') 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 } -- cgit v1.2.3