woofmt 0.1.0

An extremely fast Go linter and code formatter written in Rust
Documentation

Woof ๐Ÿ•

Rust-powered Go linter โ€” Lightning fast, zero dependencies.

Woof brings Pythonic code quality tools to the Go ecosystem. It combines the familiar interface of Ruff with Go-specific linting rules, enabling you to:

  • โšก Lint at Speed โ€” Parallel processing with Rayon for maximum throughput
  • ๐ŸŽจ Format Consistently โ€” Opinionated Go code formatting
  • ๐Ÿ”ง Auto-Fix Issues โ€” Automatically fix common code problems
  • ๐Ÿ“ฆ Single Binary โ€” Zero runtime dependencies, just one executable

Whether you're working on a small Go module or a large monorepo, Woof provides the tools you need to maintain code quality.

Features

Feature Description
โšก Blazing Fast Written in Rust, parallel file processing
๐Ÿ”ง Auto-Fix Automatically fix common issues with --fix
๐ŸŽฏ Go-Native Designed specifically for Go code patterns
๐Ÿ“Š JSON Output CI-friendly output with --format json
๐Ÿ”Œ GitHub Actions Native GitHub Actions annotation support
๐Ÿ“ Configurable TOML-based configuration (woof.toml)
๐Ÿงช Tree-sitter Precise parsing with tree-sitter

Requirements

  • Rust 1.70+ (for building from source)
  • Go 1.18+ (for linting Go projects)

Installation

From crates.io (coming soon)

cargo install woof

From source

git clone git@github.com:GWinfinity/woof.git
cd woof
cargo install --path .

Quick Start

# Check current directory
woof check .

# Check with auto-fix
woof check . --fix

# Format files in place
woof format .

# Initialize configuration
woof init

Usage

Linting

Check a file or directory for issues:

woof check .
woof check main.go
woof check ./...

Apply auto-fixes where possible:

woof check . --fix

Formatting

Format files in place:

woof format .
woof format main.go

Check if files are formatted (CI mode):

woof format . --check

Output to stdout:

woof format main.go --stdout

List all rules

woof rules
woof rules --all

Lint Rules

Code Name Description Severity
E001 unused-import Detects unused import statements Warning
E101 line-too-long Line exceeds maximum length Error
E201 trailing-whitespace Line has trailing whitespace Warning
E301 empty-block Block contains no statements Error
E401 mixed-tabs-spaces Indentation uses both tabs and spaces Error
D001 exported-missing-doc Exported identifier missing documentation Warning

Configuration

Initialize a configuration file:

woof init           # Standard config
woof init --strict  # Strict mode

Example woof.toml

# Woof configuration
[global]
target_go_version = "1.21"
respect_gitignore = true
exclude = ["vendor/", "*.gen.go"]

[linter]
select = ["E", "W", "D"]
ignore = ["E101"]

[linter.rules.line-too-long]
enabled = true
severity = "error"
options = { max_length = 100 }

[formatter]
use_tabs = true
tab_width = 4
line_length = 120
simplify = false

Command Line Options

Global Options

Option Description
--all Enable all lint rules
--ignore <RULES> Disable specific rules (comma-separated)
--select <RULES> Select specific rules (comma-separated)
--config <FILE> Configuration file path
--threads <N> Number of threads to use
--format <FORMAT> Output format: text, json, github

Check Options

Option Description
--fix Apply auto-fixes where possible
--exit-non-zero-on-fix Exit with error code if fixes applied

Format Options

Option Description
--check Check if files are formatted without modifying
--stdout Write formatted output to stdout

Project Structure

Woof/
โ”œโ”€โ”€ ๐Ÿ“ src/
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ rules/          # Lint rules implementation
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ formatter/      # Code formatter
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ config/         # Configuration handling
โ”‚   โ””โ”€โ”€ main.rs            # Entry point
โ”œโ”€โ”€ ๐Ÿ“ benches/            # Performance benchmarks
โ”œโ”€โ”€ ๐Ÿ“ testdata/           # Test fixtures
โ”œโ”€โ”€ ๐Ÿ“„ Cargo.toml          # Rust project config
โ”œโ”€โ”€ ๐Ÿ“„ woof.toml           # Example configuration
โ””โ”€โ”€ ๐Ÿ“„ README.md           # This file

Platform Support

Platform Status Recommendation
Linux โœ… Fully Supported โญ Production
macOS โœ… Fully Supported โญ Production
Windows โœ… Fully Supported Development/Testing

Development

Building

cargo build --release

Testing

cargo test

Running benchmarks

cargo bench

Adding a new rule

  1. Create a new struct in src/rules/builtin.rs
  2. Implement the Rule trait
  3. Add the rule to get_all_rules() in src/rules/mod.rs

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the Apache License 2.0. See LICENSE for more information.

Made with โค๏ธ by GWinfinity

Acknowledgments

  • Inspired by Ruff โ€” An extremely fast Python linter
  • Uses tree-sitter for parsing