format with gofumpt (#18184)
* gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
This commit is contained in:
parent
1d98d205f5
commit
54e9ee37a7
423 changed files with 1585 additions and 1758 deletions
|
@ -136,7 +136,7 @@ func (fc *fileCollector) collectFiles() (res [][]string, err error) {
|
|||
}
|
||||
|
||||
// substArgFiles expands the {file-list} to a real file list for commands
|
||||
func substArgFiles(args []string, files []string) []string {
|
||||
func substArgFiles(args, files []string) []string {
|
||||
for i, s := range args {
|
||||
if s == "{file-list}" {
|
||||
newArgs := append(args[:i], files...)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"github.com/shurcooL/vfsgen"
|
||||
)
|
||||
|
||||
func needsUpdate(dir string, filename string) (bool, []byte) {
|
||||
func needsUpdate(dir, filename string) (bool, []byte) {
|
||||
needRegen := false
|
||||
_, err := os.Stat(filename)
|
||||
if err != nil {
|
||||
|
@ -50,7 +50,6 @@ func needsUpdate(dir string, filename string) (bool, []byte) {
|
|||
newHash := hasher.Sum([]byte{})
|
||||
|
||||
if bytes.Compare(oldHash, newHash) != 0 {
|
||||
|
||||
return true, newHash
|
||||
}
|
||||
|
||||
|
@ -87,5 +86,5 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
_ = os.WriteFile(filename+".hash", newHash, 0666)
|
||||
_ = os.WriteFile(filename+".hash", newHash, 0o666)
|
||||
}
|
||||
|
|
|
@ -30,9 +30,7 @@ const (
|
|||
maxUnicodeVersion = 12
|
||||
)
|
||||
|
||||
var (
|
||||
flagOut = flag.String("o", "modules/emoji/emoji_data.go", "out")
|
||||
)
|
||||
var flagOut = flag.String("o", "modules/emoji/emoji_data.go", "out")
|
||||
|
||||
// Gemoji is a set of emoji data.
|
||||
type Gemoji []Emoji
|
||||
|
@ -68,7 +66,7 @@ func main() {
|
|||
}
|
||||
|
||||
// write
|
||||
err = os.WriteFile(*flagOut, buf, 0644)
|
||||
err = os.WriteFile(*flagOut, buf, 0o644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -109,7 +107,7 @@ func generate() ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var skinTones = make(map[string]string)
|
||||
skinTones := make(map[string]string)
|
||||
|
||||
skinTones["\U0001f3fb"] = "Light Skin Tone"
|
||||
skinTones["\U0001f3fc"] = "Medium-Light Skin Tone"
|
||||
|
@ -119,7 +117,7 @@ func generate() ([]byte, error) {
|
|||
|
||||
var tmp Gemoji
|
||||
|
||||
//filter out emoji that require greater than max unicode version
|
||||
// filter out emoji that require greater than max unicode version
|
||||
for i := range data {
|
||||
val, _ := strconv.ParseFloat(data[i].UnicodeVersion, 64)
|
||||
if int(val) <= maxUnicodeVersion {
|
||||
|
@ -158,7 +156,7 @@ func generate() ([]byte, error) {
|
|||
|
||||
// write a JSON file to use with tribute (write before adding skin tones since we can't support them there yet)
|
||||
file, _ := json.Marshal(data)
|
||||
_ = os.WriteFile("assets/emoji.json", file, 0644)
|
||||
_ = os.WriteFile("assets/emoji.json", file, 0o644)
|
||||
|
||||
// Add skin tones to emoji that support it
|
||||
var (
|
||||
|
|
|
@ -34,7 +34,6 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
file, err := os.CreateTemp(os.TempDir(), prefix)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create temp file. %s", err)
|
||||
}
|
||||
|
@ -65,7 +64,6 @@ func main() {
|
|||
}
|
||||
|
||||
gz, err := gzip.NewReader(file)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to gunzip the archive. %s", err)
|
||||
}
|
||||
|
@ -96,7 +94,6 @@ func main() {
|
|||
}
|
||||
|
||||
out, err := os.Create(path.Join(destination, strings.TrimSuffix(filepath.Base(hdr.Name), ".gitignore")))
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create new file. %s", err)
|
||||
}
|
||||
|
@ -119,7 +116,7 @@ func main() {
|
|||
}
|
||||
// Write data to dst
|
||||
dst = path.Join(destination, dst)
|
||||
err = os.WriteFile(dst, data, 0644)
|
||||
err = os.WriteFile(dst, data, 0o644)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to write new file. %s", err)
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
file, err := os.CreateTemp(os.TempDir(), prefix)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create temp file. %s", err)
|
||||
}
|
||||
|
@ -66,7 +65,6 @@ func main() {
|
|||
}
|
||||
|
||||
gz, err := gzip.NewReader(file)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to gunzip the archive. %s", err)
|
||||
}
|
||||
|
@ -100,7 +98,6 @@ func main() {
|
|||
continue
|
||||
}
|
||||
out, err := os.Create(path.Join(destination, strings.TrimSuffix(filepath.Base(hdr.Name), ".txt")))
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create new file. %s", err)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
"golang.org/x/tools/cover"
|
||||
)
|
||||
|
||||
func mergeProfiles(p *cover.Profile, merge *cover.Profile) {
|
||||
func mergeProfiles(p, merge *cover.Profile) {
|
||||
if p.Mode != merge.Mode {
|
||||
log.Fatalf("cannot merge profiles with different modes")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue