From d438731b8b403afeff22719de15a2ec98ba7c305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Fri, 8 May 2026 11:52:11 +0800 Subject: [PATCH 1/6] Add dry-run Go source format check --- .github/workflows/test.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c07983a46aa0..e58d16383ced 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,6 +50,32 @@ jobs: fi done + check-format: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout codebase + uses: actions/checkout@v6 + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + check-latest: true + - name: Check Format + run: | + DIFFFILE=$(gofmt -l ./) + if [ -n "${DIFFFILE}" ]; then + echo "Format problem found. Run 'go fmt -x ./...' or 'gofmt -w ./' to format the go files." + echo "Here are the list of files:" + echo "${DIFFFILE}" + echo "Here are the formatting problem currently found:" + gofmt -d ./ + exit 1 + else + echo "Source file format check passed." + fi + test: needs: check-assets permissions: From 94e4df005c791df4d03cdc1dbd60810e62d280f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Fri, 8 May 2026 12:37:34 +0800 Subject: [PATCH 2/6] Refinements --- .github/workflows/test.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e58d16383ced..a87fc61ca361 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Test +name: Tests and Checkings on: push: @@ -62,14 +62,15 @@ jobs: with: go-version-file: go.mod check-latest: true + cache: false - name: Check Format run: | DIFFFILE=$(gofmt -l ./) if [ -n "${DIFFFILE}" ]; then - echo "Format problem found. Run 'go fmt -x ./...' or 'gofmt -w ./' to format the go files." - echo "Here are the list of files:" + echo "Format problem(s) found. Run 'go fmt -x ./...' or 'gofmt -w ./' to format the go files." + echo "Here are the list of file(s):" echo "${DIFFFILE}" - echo "Here are the formatting problem currently found:" + echo "Here are the format problem(s) currently found:" gofmt -d ./ exit 1 else From 3d04ab8fec7fd725a0299167a3fc8affe3813c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Fri, 8 May 2026 15:34:49 +0800 Subject: [PATCH 3/6] Use vformat instead of gofmt --- .github/check/format_dryrun.go | 218 +++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 14 +-- infra/vformat/main.go | 2 +- 3 files changed, 222 insertions(+), 12 deletions(-) create mode 100644 .github/check/format_dryrun.go diff --git a/.github/check/format_dryrun.go b/.github/check/format_dryrun.go new file mode 100644 index 000000000000..cadf0b0c91c2 --- /dev/null +++ b/.github/check/format_dryrun.go @@ -0,0 +1,218 @@ +package main + +import ( + "errors" + "flag" + "fmt" + "go/build" + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" +) + +var directory = flag.String("pwd", "", "Working directory of Xray vformat.") + +// envFile returns the name of the Go environment configuration file. +// Copy from https://github.com/golang/go/blob/c4f2a9788a7be04daf931ac54382fbe2cb754938/src/cmd/go/internal/cfg/cfg.go#L150-L166 +func envFile() (string, error) { + if file := os.Getenv("GOENV"); file != "" { + if file == "off" { + return "", errors.New("GOENV=off") + } + return file, nil + } + dir, err := os.UserConfigDir() + if err != nil { + return "", err + } + if dir == "" { + return "", errors.New("missing user-config dir") + } + return filepath.Join(dir, "go", "env"), nil +} + +// GetRuntimeEnv returns the value of runtime environment variable, +// that is set by running following command: `go env -w key=value`. +func GetRuntimeEnv(key string) (string, error) { + file, err := envFile() + if err != nil { + return "", err + } + if file == "" { + return "", errors.New("missing runtime env file") + } + var data []byte + var runtimeEnv string + data, readErr := os.ReadFile(file) + if readErr != nil { + return "", readErr + } + envStrings := strings.Split(string(data), "\n") + for _, envItem := range envStrings { + envItem = strings.TrimSuffix(envItem, "\r") + envKeyValue := strings.Split(envItem, "=") + if len(envKeyValue) == 2 && strings.TrimSpace(envKeyValue[0]) == key { + runtimeEnv = strings.TrimSpace(envKeyValue[1]) + } + } + return runtimeEnv, nil +} + +// GetGOBIN returns GOBIN environment variable as a string. It will NOT be empty. +func GetGOBIN() string { + // The one set by user explicitly by `export GOBIN=/path` or `env GOBIN=/path command` + GOBIN := os.Getenv("GOBIN") + if GOBIN == "" { + var err error + // The one set by user by running `go env -w GOBIN=/path` + GOBIN, err = GetRuntimeEnv("GOBIN") + if err != nil { + // The default one that Golang uses + return filepath.Join(build.Default.GOPATH, "bin") + } + if GOBIN == "" { + return filepath.Join(build.Default.GOPATH, "bin") + } + return GOBIN + } + return GOBIN +} + +func Run(binary string, args []string) ([]byte, error) { + cmd := exec.Command(binary, args...) + cmd.Env = append(cmd.Env, os.Environ()...) + output, cmdErr := cmd.CombinedOutput() + if cmdErr != nil { + return nil, cmdErr + } + return output, nil +} + +func RunMany(binary string, args, files []string) bool { + fmt.Println("Processing with", binary, args, "...") + + formatRequired := false + maxTasks := make(chan struct{}, runtime.NumCPU()) + for _, file := range files { + maxTasks <- struct{}{} + go func(file string) { + output, err := Run(binary, append(args, file)) + if err != nil { + fmt.Println(err) + } else if len(output) > 0 { + fmt.Println(string(output)) + formatRequired = true + } + <-maxTasks + }(file) + } + return formatRequired +} + +func main() { + flag.Usage = func() { + fmt.Fprintf(flag.CommandLine.Output(), "Usage of vformat:\n") + flag.PrintDefaults() + } + flag.Parse() + + if !filepath.IsAbs(*directory) { + pwd, wdErr := os.Getwd() + if wdErr != nil { + fmt.Println("Can not get current working directory.") + os.Exit(1) + } + *directory = filepath.Join(pwd, *directory) + } + + pwd := *directory + GOBIN := GetGOBIN() + binPath := os.Getenv("PATH") + pathSlice := []string{pwd, GOBIN, binPath} + binPath = strings.Join(pathSlice, string(os.PathListSeparator)) + os.Setenv("PATH", binPath) + + suffix := "" + if runtime.GOOS == "windows" { + suffix = ".exe" + } + gofmt := "gofumpt" + suffix + goimports := "gci" + suffix + + if gofmtPath, err := exec.LookPath(gofmt); err != nil { + fmt.Println("Can not find", gofmt, "in system path or current working directory.") + os.Exit(1) + } else { + gofmt = gofmtPath + } + + if goimportsPath, err := exec.LookPath(goimports); err != nil { + fmt.Println("Can not find", goimports, "in system path or current working directory.") + os.Exit(1) + } else { + goimports = goimportsPath + } + + rawFilesSlice := make([]string, 0, 1000) + walkErr := filepath.Walk(pwd, func(path string, info os.FileInfo, err error) error { + if err != nil { + fmt.Println(err) + return err + } + + if info.IsDir() { + return nil + } + + dir := filepath.Dir(path) + filename := filepath.Base(path) + if strings.HasSuffix(filename, ".go") && + !strings.HasSuffix(filename, ".pb.go") && + !strings.Contains(dir, filepath.Join("testing", "mocks")) && + !strings.Contains(path, filepath.Join("main", "distro", "all", "all.go")) { + rawFilesSlice = append(rawFilesSlice, path) + } + + return nil + }) + if walkErr != nil { + fmt.Println(walkErr) + os.Exit(1) + } + + gofmtListArgs := []string{ + "-l", "-e", + } + + gofmtShowArgs := []string{ + "-d", "-e", + } + + goimportsListArgs := []string{ + "list", + } + + goimportsShowArgs := []string{ + "diff", + } + + fmt.Println("Checking files thar are not properly formatted...") + formatRequired := RunMany(gofmt, gofmtListArgs, rawFilesSlice) + formatImportRequired := RunMany(goimports, goimportsListArgs, rawFilesSlice) + if formatRequired { + fmt.Println("Format problem(s) found.") + RunMany(gofmt, gofmtShowArgs, rawFilesSlice) + } + if formatImportRequired { + fmt.Println("Format problem(s) in import found.") + RunMany(goimports, goimportsShowArgs, rawFilesSlice) + } + if formatRequired || formatImportRequired { + fmt.Println("Please run 'go install -v github.com/daixiang0/gci@latest', 'go install -v mvdan.cc/gofumpt@latest', then run 'go run ./infra/vformat/main.go' to format the Go source files.") + os.Exit(1) + } else { + fmt.Println("All Go source file format check has been passed.") + } +} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a87fc61ca361..d48ffcc77f6b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,17 +65,9 @@ jobs: cache: false - name: Check Format run: | - DIFFFILE=$(gofmt -l ./) - if [ -n "${DIFFFILE}" ]; then - echo "Format problem(s) found. Run 'go fmt -x ./...' or 'gofmt -w ./' to format the go files." - echo "Here are the list of file(s):" - echo "${DIFFFILE}" - echo "Here are the format problem(s) currently found:" - gofmt -d ./ - exit 1 - else - echo "Source file format check passed." - fi + go install -v github.com/daixiang0/gci@latest + go install -v mvdan.cc/gofumpt@latest + go run ./.github/check/format_dryrun.go -pwd ./ test: needs: check-assets diff --git a/infra/vformat/main.go b/infra/vformat/main.go index 84c63a4203cc..7a456f4da0ed 100644 --- a/infra/vformat/main.go +++ b/infra/vformat/main.go @@ -180,7 +180,7 @@ func main() { } gofmtArgs := []string{ - "-s", "-l", "-e", "-w", + "-l", "-e", "-w", } goimportsArgs := []string{ From dcad6b207090a2ebaa031d4be7855467405eab8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Fri, 8 May 2026 21:27:10 +0800 Subject: [PATCH 4/6] Enchance vformat --- .github/check/format_dryrun.go | 218 --------------------------------- .github/workflows/test.yml | 2 +- infra/vformat/main.go | 90 ++++++++++++-- 3 files changed, 80 insertions(+), 230 deletions(-) delete mode 100644 .github/check/format_dryrun.go diff --git a/.github/check/format_dryrun.go b/.github/check/format_dryrun.go deleted file mode 100644 index cadf0b0c91c2..000000000000 --- a/.github/check/format_dryrun.go +++ /dev/null @@ -1,218 +0,0 @@ -package main - -import ( - "errors" - "flag" - "fmt" - "go/build" - "os" - "os/exec" - "path/filepath" - "runtime" - "strings" -) - -var directory = flag.String("pwd", "", "Working directory of Xray vformat.") - -// envFile returns the name of the Go environment configuration file. -// Copy from https://github.com/golang/go/blob/c4f2a9788a7be04daf931ac54382fbe2cb754938/src/cmd/go/internal/cfg/cfg.go#L150-L166 -func envFile() (string, error) { - if file := os.Getenv("GOENV"); file != "" { - if file == "off" { - return "", errors.New("GOENV=off") - } - return file, nil - } - dir, err := os.UserConfigDir() - if err != nil { - return "", err - } - if dir == "" { - return "", errors.New("missing user-config dir") - } - return filepath.Join(dir, "go", "env"), nil -} - -// GetRuntimeEnv returns the value of runtime environment variable, -// that is set by running following command: `go env -w key=value`. -func GetRuntimeEnv(key string) (string, error) { - file, err := envFile() - if err != nil { - return "", err - } - if file == "" { - return "", errors.New("missing runtime env file") - } - var data []byte - var runtimeEnv string - data, readErr := os.ReadFile(file) - if readErr != nil { - return "", readErr - } - envStrings := strings.Split(string(data), "\n") - for _, envItem := range envStrings { - envItem = strings.TrimSuffix(envItem, "\r") - envKeyValue := strings.Split(envItem, "=") - if len(envKeyValue) == 2 && strings.TrimSpace(envKeyValue[0]) == key { - runtimeEnv = strings.TrimSpace(envKeyValue[1]) - } - } - return runtimeEnv, nil -} - -// GetGOBIN returns GOBIN environment variable as a string. It will NOT be empty. -func GetGOBIN() string { - // The one set by user explicitly by `export GOBIN=/path` or `env GOBIN=/path command` - GOBIN := os.Getenv("GOBIN") - if GOBIN == "" { - var err error - // The one set by user by running `go env -w GOBIN=/path` - GOBIN, err = GetRuntimeEnv("GOBIN") - if err != nil { - // The default one that Golang uses - return filepath.Join(build.Default.GOPATH, "bin") - } - if GOBIN == "" { - return filepath.Join(build.Default.GOPATH, "bin") - } - return GOBIN - } - return GOBIN -} - -func Run(binary string, args []string) ([]byte, error) { - cmd := exec.Command(binary, args...) - cmd.Env = append(cmd.Env, os.Environ()...) - output, cmdErr := cmd.CombinedOutput() - if cmdErr != nil { - return nil, cmdErr - } - return output, nil -} - -func RunMany(binary string, args, files []string) bool { - fmt.Println("Processing with", binary, args, "...") - - formatRequired := false - maxTasks := make(chan struct{}, runtime.NumCPU()) - for _, file := range files { - maxTasks <- struct{}{} - go func(file string) { - output, err := Run(binary, append(args, file)) - if err != nil { - fmt.Println(err) - } else if len(output) > 0 { - fmt.Println(string(output)) - formatRequired = true - } - <-maxTasks - }(file) - } - return formatRequired -} - -func main() { - flag.Usage = func() { - fmt.Fprintf(flag.CommandLine.Output(), "Usage of vformat:\n") - flag.PrintDefaults() - } - flag.Parse() - - if !filepath.IsAbs(*directory) { - pwd, wdErr := os.Getwd() - if wdErr != nil { - fmt.Println("Can not get current working directory.") - os.Exit(1) - } - *directory = filepath.Join(pwd, *directory) - } - - pwd := *directory - GOBIN := GetGOBIN() - binPath := os.Getenv("PATH") - pathSlice := []string{pwd, GOBIN, binPath} - binPath = strings.Join(pathSlice, string(os.PathListSeparator)) - os.Setenv("PATH", binPath) - - suffix := "" - if runtime.GOOS == "windows" { - suffix = ".exe" - } - gofmt := "gofumpt" + suffix - goimports := "gci" + suffix - - if gofmtPath, err := exec.LookPath(gofmt); err != nil { - fmt.Println("Can not find", gofmt, "in system path or current working directory.") - os.Exit(1) - } else { - gofmt = gofmtPath - } - - if goimportsPath, err := exec.LookPath(goimports); err != nil { - fmt.Println("Can not find", goimports, "in system path or current working directory.") - os.Exit(1) - } else { - goimports = goimportsPath - } - - rawFilesSlice := make([]string, 0, 1000) - walkErr := filepath.Walk(pwd, func(path string, info os.FileInfo, err error) error { - if err != nil { - fmt.Println(err) - return err - } - - if info.IsDir() { - return nil - } - - dir := filepath.Dir(path) - filename := filepath.Base(path) - if strings.HasSuffix(filename, ".go") && - !strings.HasSuffix(filename, ".pb.go") && - !strings.Contains(dir, filepath.Join("testing", "mocks")) && - !strings.Contains(path, filepath.Join("main", "distro", "all", "all.go")) { - rawFilesSlice = append(rawFilesSlice, path) - } - - return nil - }) - if walkErr != nil { - fmt.Println(walkErr) - os.Exit(1) - } - - gofmtListArgs := []string{ - "-l", "-e", - } - - gofmtShowArgs := []string{ - "-d", "-e", - } - - goimportsListArgs := []string{ - "list", - } - - goimportsShowArgs := []string{ - "diff", - } - - fmt.Println("Checking files thar are not properly formatted...") - formatRequired := RunMany(gofmt, gofmtListArgs, rawFilesSlice) - formatImportRequired := RunMany(goimports, goimportsListArgs, rawFilesSlice) - if formatRequired { - fmt.Println("Format problem(s) found.") - RunMany(gofmt, gofmtShowArgs, rawFilesSlice) - } - if formatImportRequired { - fmt.Println("Format problem(s) in import found.") - RunMany(goimports, goimportsShowArgs, rawFilesSlice) - } - if formatRequired || formatImportRequired { - fmt.Println("Please run 'go install -v github.com/daixiang0/gci@latest', 'go install -v mvdan.cc/gofumpt@latest', then run 'go run ./infra/vformat/main.go' to format the Go source files.") - os.Exit(1) - } else { - fmt.Println("All Go source file format check has been passed.") - } -} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d48ffcc77f6b..4547ac835093 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -67,7 +67,7 @@ jobs: run: | go install -v github.com/daixiang0/gci@latest go install -v mvdan.cc/gofumpt@latest - go run ./.github/check/format_dryrun.go -pwd ./ + go run ./infra/vformat/main.go -mode dryrun -pwd ./ test: needs: check-assets diff --git a/infra/vformat/main.go b/infra/vformat/main.go index 7a456f4da0ed..4d8a3da07809 100644 --- a/infra/vformat/main.go +++ b/infra/vformat/main.go @@ -12,7 +12,16 @@ import ( "strings" ) -var directory = flag.String("pwd", "", "Working directory of Xray vformat.") +var ( + directory = flag.String("pwd", "", "Working directory of Xray vformat.") + action = flag.String("mode", "format", "Execution mode. Default is 'format'.\n'format' formatting source files and save changes to files.\n'check' list all paths of improper formatted file.\n'dryrun' formatting source files and shows all diffs, but will not make any changes to files.") +) + +var ( + isCheck bool + isDryrun bool + isFormat bool +) // envFile returns the name of the Go environment configuration file. // Copy from https://github.com/golang/go/blob/c4f2a9788a7be04daf931ac54382fbe2cb754938/src/cmd/go/internal/cfg/cfg.go#L150-L166 @@ -90,9 +99,10 @@ func Run(binary string, args []string) ([]byte, error) { return output, nil } -func RunMany(binary string, args, files []string) { - fmt.Println("Processing...") +func RunMany(binary string, args, files []string) bool { + fmt.Println("Processing with", binary, args, "...") + formatRequired := false maxTasks := make(chan struct{}, runtime.NumCPU()) for _, file := range files { maxTasks <- struct{}{} @@ -102,10 +112,12 @@ func RunMany(binary string, args, files []string) { fmt.Println(err) } else if len(output) > 0 { fmt.Println(string(output)) + formatRequired = true } <-maxTasks }(file) } + return formatRequired } func main() { @@ -124,6 +136,19 @@ func main() { *directory = filepath.Join(pwd, *directory) } + switch *action { + case "format": + isFormat = true + case "check": + isCheck = true + case "dryrun": + isCheck = true + isDryrun = true + default: + fmt.Println("Unrecognized 'mode'. Will format all source files and save changes.") + isFormat = true + } + pwd := *directory GOBIN := GetGOBIN() binPath := os.Getenv("PATH") @@ -179,15 +204,58 @@ func main() { os.Exit(1) } - gofmtArgs := []string{ - "-l", "-e", "-w", - } + if isFormat { + gofmtArgs := []string{ + "-l", "-e", "-w", + } + goimportsArgs := []string{ + "write", + } - goimportsArgs := []string{ - "write", + fmt.Println("Formatting Go source files...") + RunMany(gofmt, gofmtArgs, rawFilesSlice) + RunMany(goimports, goimportsArgs, rawFilesSlice) + fmt.Println("Do NOT forget to commit file changes.") } - RunMany(gofmt, gofmtArgs, rawFilesSlice) - RunMany(goimports, goimportsArgs, rawFilesSlice) - fmt.Println("Do NOT forget to commit file changes.") + if isCheck { + gofmtListArgs := []string{ + "-l", "-e", + } + goimportsListArgs := []string{ + "list", + } + + fmt.Println("Checking files thar are not properly formatted...") + formatRequired := RunMany(gofmt, gofmtListArgs, rawFilesSlice) + formatImportRequired := RunMany(goimports, goimportsListArgs, rawFilesSlice) + if formatRequired { + fmt.Println("Format problem(s) found.") + } + if formatImportRequired { + fmt.Println("Format problem(s) in import found.") + } + + if isDryrun { + if formatRequired { + gofmtShowArgs := []string{ + "-d", "-e", + } + RunMany(gofmt, gofmtShowArgs, rawFilesSlice) + } + if formatImportRequired { + goimportsShowArgs := []string{ + "diff", + } + RunMany(goimports, goimportsShowArgs, rawFilesSlice) + } + } + + if formatRequired || formatImportRequired { + fmt.Println("Please run 'go install -v github.com/daixiang0/gci@latest', 'go install -v mvdan.cc/gofumpt@latest', then run 'go run ./infra/vformat/main.go' to format the Go source files.") + os.Exit(1) + } else { + fmt.Println("All Go source file format check has been passed.") + } + } } From 3708571e88c7ee914c2328a4b5a2e435e9f75dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Fri, 8 May 2026 23:13:26 +0800 Subject: [PATCH 5/6] Temporarily disable gci --- .github/workflows/test.yml | 2 +- infra/vformat/main.go | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4547ac835093..814cd8a38826 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,7 +65,7 @@ jobs: cache: false - name: Check Format run: | - go install -v github.com/daixiang0/gci@latest + # go install -v github.com/daixiang0/gci@latest go install -v mvdan.cc/gofumpt@latest go run ./infra/vformat/main.go -mode dryrun -pwd ./ diff --git a/infra/vformat/main.go b/infra/vformat/main.go index 4d8a3da07809..a68b507b1b5b 100644 --- a/infra/vformat/main.go +++ b/infra/vformat/main.go @@ -161,7 +161,7 @@ func main() { suffix = ".exe" } gofmt := "gofumpt" + suffix - goimports := "gci" + suffix + /* goimports := "gci" + suffix */ if gofmtPath, err := exec.LookPath(gofmt); err != nil { fmt.Println("Can not find", gofmt, "in system path or current working directory.") @@ -170,12 +170,12 @@ func main() { gofmt = gofmtPath } - if goimportsPath, err := exec.LookPath(goimports); err != nil { + /* if goimportsPath, err := exec.LookPath(goimports); err != nil { fmt.Println("Can not find", goimports, "in system path or current working directory.") os.Exit(1) } else { goimports = goimportsPath - } + } */ rawFilesSlice := make([]string, 0, 1000) walkErr := filepath.Walk(pwd, func(path string, info os.FileInfo, err error) error { @@ -208,13 +208,13 @@ func main() { gofmtArgs := []string{ "-l", "-e", "-w", } - goimportsArgs := []string{ + /* goimportsArgs := []string{ "write", - } + } */ fmt.Println("Formatting Go source files...") RunMany(gofmt, gofmtArgs, rawFilesSlice) - RunMany(goimports, goimportsArgs, rawFilesSlice) + /* (goimports, goimportsArgs, rawFilesSlice) */ fmt.Println("Do NOT forget to commit file changes.") } @@ -222,19 +222,19 @@ func main() { gofmtListArgs := []string{ "-l", "-e", } - goimportsListArgs := []string{ + /* goimportsListArgs := []string{ "list", - } + } */ fmt.Println("Checking files thar are not properly formatted...") formatRequired := RunMany(gofmt, gofmtListArgs, rawFilesSlice) - formatImportRequired := RunMany(goimports, goimportsListArgs, rawFilesSlice) + /* formatImportRequired := RunMany(goimports, goimportsListArgs, rawFilesSlice) */ if formatRequired { fmt.Println("Format problem(s) found.") } - if formatImportRequired { + /* if formatImportRequired { fmt.Println("Format problem(s) in import found.") - } + } */ if isDryrun { if formatRequired { @@ -243,15 +243,16 @@ func main() { } RunMany(gofmt, gofmtShowArgs, rawFilesSlice) } - if formatImportRequired { + /* formatImportRequired { goimportsShowArgs := []string{ "diff", } RunMany(goimports, goimportsShowArgs, rawFilesSlice) - } + } */ } - if formatRequired || formatImportRequired { + /* if formatRequired || formatImportRequired { */ + if formatRequired { fmt.Println("Please run 'go install -v github.com/daixiang0/gci@latest', 'go install -v mvdan.cc/gofumpt@latest', then run 'go run ./infra/vformat/main.go' to format the Go source files.") os.Exit(1) } else { From 7e679140ae89665ca920debf2d9521b727fbee17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Fri, 8 May 2026 23:25:33 +0800 Subject: [PATCH 6/6] . --- infra/vformat/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/infra/vformat/main.go b/infra/vformat/main.go index a68b507b1b5b..81d29c6bc0d2 100644 --- a/infra/vformat/main.go +++ b/infra/vformat/main.go @@ -253,7 +253,9 @@ func main() { /* if formatRequired || formatImportRequired { */ if formatRequired { - fmt.Println("Please run 'go install -v github.com/daixiang0/gci@latest', 'go install -v mvdan.cc/gofumpt@latest', then run 'go run ./infra/vformat/main.go' to format the Go source files.") + /* fmt.Println("Please run 'go install -v github.com/daixiang0/gci@latest', 'go install -v mvdan.cc/gofumpt@latest', then run 'go run ./infra/vformat/main.go' to format the Go source files.") + os.Exit(1) */ + fmt.Println("Please run 'go install -v mvdan.cc/gofumpt@latest', then run 'go run ./infra/vformat/main.go' to format the Go source files.") os.Exit(1) } else { fmt.Println("All Go source file format check has been passed.")