format with gofumpt (#18184)

* gofumpt -w -l .

* gofumpt -w -l -extra .

* Add linter

* manual fix

* change make fmt
This commit is contained in:
6543 2022-01-20 18:46:10 +01:00 committed by GitHub
parent 1d98d205f5
commit 54e9ee37a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
423 changed files with 1585 additions and 1758 deletions

View file

@ -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
}