gofmt vs Ruff
gofmt
go.devRuff
docs.astral.shSide by side
| Figure | gofmt | Ruff |
|---|---|---|
| Price from | Free | Free |
| Free plan | Yes | Yes |
| Free trial | — | — |
| Open source | — | — |
| Web | — | Yes |
| Windows | Yes | Yes |
| macOS | Yes | Yes |
| Linux | Yes | Yes |
| Self-hosted | — | Yes |
| Plans published | 1 | 1 |
| Spec score · Code Formatting Tools | 7.8 (#13) | 7.9 (#12) |
| Editor integrations | The Go project documents gofmt integrations for Vim, Emacs, Eclipse, Sublime Text, Git pre-commit hooks, and Mercurial. | The setup guide documents integrations including VS Code, Sublime Text, PyCharm, and Zed. |
| Purpose | Gofmt automatically formats Go programs using tabs for indentation and blanks for alignment. | Ruff is a Python linter and code formatter written in Rust. |
| Security | The Go project issues security fixes to the two most recent major Go releases and provides a security policy for reporting vulnerabilities. | Ruff’s rules include a Bandit-derived group for detecting common security issues, including possible vulnerabilities in Python code. |
| Support | Questions about using Go or announcements relevant to Go users should be sent to the golang-nuts mailing list. | The editor setup documentation says setup instructions are provided on a best-effort basis and directs users to open an issue for assistance. |
Plans
In their own words
gofmt
gofmt is the Go source formatter distributed with Go installations, available on Linux, macOS, and Windows. It formats Go programs using tabs for indentation and spaces for alignment. With no path, it reads standard input; given a directory, it processes .go files recursively while skipping files whose names begin with a period. By default, reformatted source is written to standard output. Flags can show differences, list files that need formatting, apply rewrite rules, simplify code, or report all errors. The rewrite option uses patterns and replacements written as valid Go expressions. gofmt can also arrange documentation comments into canonical paragraphs, lists, headings, links, and code blocks. The Go project documents integrations for Vim, Emacs, Eclipse, and Sublime Text, plus Git pre-commit hooks and Mercurial. Since Go 1.18, it reads and formats files concurrently, with memory use limited in proportion to GOMAXPROCS. The executable is equivalent to go fmt. It is free, included in the Go installation, and distributed under a BSD-style license.
Ruff
Ruff is a Python linter and code formatter written in Rust, available free under a permissive open-source license. It includes more than 900 built-in lint rules, including native versions of popular Flake8 plugin rules, and can automatically correct violations such as unused imports. Its formatter aims to serve as a replacement for Black, though the documentation allows for differences in some cases. The built-in Ruff Language Server supplies diagnostics, fixes, and formatting; the documentation recommends pairing it with another Python language server for navigation and autocompletion. Setup guidance covers VS Code, Sublime Text, PyCharm, and Zed, while CI support includes GitHub Actions, GitLab CI/CD, and pre-commit hooks. Ruff can be installed through uv, pip, pipx, standalone installers, Homebrew, Conda, and other package managers. It supports configuration in pyproject.toml, ruff.toml, or .ruff.toml. A Bandit-derived rule group checks for common Python security issues. Ruff runs on Linux, macOS, and Windows, and is also published as a Docker image. The maker describes it as 10–100x faster than tools such as Flake8 and Black.