Expand description
§Woof 🐕
An extremely fast Go linter and code formatter written in Rust.
§Features
- ⚡ Blazing Fast — Parallel processing with Rayon for maximum throughput
- 🔧 Auto-Fix — Automatically fix common issues
- 🎯 Go-Native — Designed specifically for Go code patterns
- 📊 Multiple Output Formats — Text, JSON, and GitHub Actions annotations
- 📝 Configurable — TOML-based configuration
- 🧪 Tree-sitter — Precise parsing with tree-sitter
§Quick Start
§As a CLI tool
# Install
cargo install woofmt
# Check current directory
woof check .
# Check with auto-fix
woof check . --fix
# Format files
woof format .§As a library
[dependencies]
woofmt = "0.1.0"use woofmt::{lint_path, format_path, config::Config};
// Load configuration
let config = Config::load(None).unwrap();
// Lint a file or directory
let diagnostics = lint_path("./src", &config).unwrap();
for diag in diagnostics {
println!("{}: {}", diag.severity, diag.message);
}
// Format a file or directory
let result = format_path("./src", false, &config).unwrap();
println!("Formatted {} files", result.files_formatted);§Architecture
The library is organized into several modules:
| Module | Description |
|---|---|
linter | Linting engine and diagnostic generation |
formatter | Code formatting engine |
rules | Lint rules implementation |
config | Configuration handling |
parser | Parser pool for efficient AST parsing |
§Lint Rules
| Code | Name | Description | Severity |
|---|---|---|---|
| E001 | unused-import | Unused import statements | Warning |
| E101 | line-too-long | Line exceeds maximum length | Error |
| E201 | trailing-whitespace | Lines with trailing whitespace | Warning |
| E301 | empty-block | Empty code blocks | Error |
| E401 | mixed-tabs-spaces | Mixed indentation | Error |
| D001 | exported-missing-doc | Missing documentation | Warning |
§Performance
Woof is designed for speed:
- Parallel processing — Uses Rayon for data parallelism
- Parser pool — Reuses tree-sitter parsers to avoid initialization overhead
- Zero-copy I/O — Memory-mapped file reading where possible
- Memory arena — Efficient memory allocation for AST nodes
§Configuration
Create a woof.toml file in your project root:
[global]
target_go_version = "1.21"
respect_gitignore = true
exclude = ["vendor/", "*.gen.go"]
[linter]
select = ["E", "W", "D"]
ignore = ["E101"]
[formatter]
use_tabs = true
tab_width = 4
line_length = 120§Links
§License
Licensed under the Apache License 2.0.
Modules§
- arena
- Arena-based memory management for AST nodes
- cli
- config
- Configuration management for Woof.
- formatter
- Code formatter for Go source code.
- io
- Zero-copy I/O and shared memory for efficient file processing
- linter
- Linting engine for Go source code.
- linter_
optimized - Memory-optimized linter with shared AST and streaming support
- linter_
parallel - Parallel linting utilities
- linter_
profiled - Profiled linting utilities for performance analysis
- logger
- Logging system for woof
- parser
- Parser pool and AST caching for efficient memory usage
- rules
- Lint rules implementation.
Macros§
Structs§
- Diagnostic
- Represents a diagnostic message from linting.
- Fix
- A fix suggestion for a diagnostic.
- Format
Result - Result of a format operation.
Enums§
- Severity
- Severity level of a diagnostic.
Functions§
- format_
path - Format a file or directory.
- format_
to_ string - Format Go source code string.
- lint_
path - Run the linter on a file or directory.