thepipefixer/goruleset icon
public
Published on 3/24/2025
Rules template

Rules
goruleset
Emphasize Clear Documentation

Use standard Go doc comments (// above functions, types, and packages) to explain intent and usage.

Highlight function parameters and return values where necessary.

Ensure Structured & Cohesive Code

Group related functions and types logically within packages.

Favor smaller, single-purpose functions over large, monolithic ones for clarity and reusability.

Practice Effective Error Handling

Always check and return errors rather than ignoring them.

Avoid panic except in truly exceptional (programming error) scenarios.

Provide context in error messages to facilitate debugging.

Adhere to Idiomatic Conventions

Use standardized naming (e.g., MixedCaps for export, lowerCamelCase for unexported).

Avoid short, unclear variable names—unless they’re truly obvious (like loop indices).

Keep if err != nil { return err } as the standard pattern.

Leverage Go’s Concurrency Wisely

Use goroutines to handle concurrent workloads, but avoid unbounded goroutine creation.

Use channels or sync mechanisms (sync.WaitGroup, sync.Mutex) only when necessary—avoid overcomplicating concurrency.

Maintain a Well-Structured Testing Strategy

Use Go’s built-in testing (testing package) to ensure reliability and prevent regressions.

Write table-driven tests to handle multiple test scenarios succinctly.

Keep tests in the same package or a _test package for clarity and maintainability.

Enforce Code Readability & Maintainability

Avoid deeply nested loops or conditionals; refactor or break them down.

Maintain consistent formatting via go fmt.

Apply linters (like golangci-lint) and vet tools for static analysis.

Strive for Simplicity & Efficiency

Choose straightforward solutions over overly clever ones—clarity wins in Go.

Only optimize where profiling indicates real performance bottlenecks.

Make it easy for future maintainers (and AI models) to understand and modify your code.