-
Type:
Task
-
Resolution: Done
-
Priority:
Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
Go Drivers
-
Not Needed
-
None
-
None
-
None
-
None
-
None
-
None
Context
Migrate etc/check_fmt.sh to a Go script under internal/cmd/check-fmt/main.go
Definition of done
- Taskfile updated to invoke the new cmd: go run ./internal/cmd/check-fmt/main.go
- etc/check_fmt.sh removed
- Equivalent error output when gofumpt or line-length checks fail
Use https://github.com/mvdan/gofumpt. This will require creating a new module at{{internal/cmd/check-fmt/main.go}}. Be sure to update go.work at root.
github.com/walle/lll is package main and has no importable API, so it will need to be invoked via os/exec. We should extract a generic exec helper into internal/scriptutil (or similar) so future Go-based scripts can share it. Example generated by Claude:
func execCmd(env []string, name string, args ...string) error { cmd := exec.Command(name, args...) if env != nil { cmd.Env = env } cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { return fmt.Errorf("%s %s: %w", name, strings.Join(args, " "), err) } return nil }
_ = execCmd(nil, "lll", "-w", "4", "-l", "80", "-e", `^\s*\/\/(.+:\/\/| Output:)`, "--files")
Pitfalls
NA
- Will require periodically updating which version of gofumpt to use
- is duplicated by
-
GODRIVER-3949 mongo-go-driver - PR #2414: GODRIVER-3936 Migrate check_fmt.sh to a Go script under internal/cmd/check-fmt
-
- Closed
-