mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 19:38:23 +00:00 
			
		
		
		
	format with gofumpt (#18184)
* gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
This commit is contained in:
		| @@ -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 | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user