Skip to main content

Crate woofmt

Crate woofmt 

Source
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:

ModuleDescription
linterLinting engine and diagnostic generation
formatterCode formatting engine
rulesLint rules implementation
configConfiguration handling
parserParser pool for efficient AST parsing

§Lint Rules

CodeNameDescriptionSeverity
E001unused-importUnused import statementsWarning
E101line-too-longLine exceeds maximum lengthError
E201trailing-whitespaceLines with trailing whitespaceWarning
E301empty-blockEmpty code blocksError
E401mixed-tabs-spacesMixed indentationError
D001exported-missing-docMissing documentationWarning

§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

§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§

log_debug
Log a debug message
log_perf
Log a performance metric
log_trace
Log a trace message

Structs§

Diagnostic
Represents a diagnostic message from linting.
Fix
A fix suggestion for a diagnostic.
FormatResult
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.