PluginBench
Rule

go

via PatrickJS/awesome-cursorrules

Idiomatic Go with explicit error handling, interface-based design, and context-first concurrency.

What is go?

Enforces Go best practices for error handling, naming conventions, interface design, and safe concurrency patterns. Use this rule to maintain consistency with Go idioms and avoid common pitfalls like silent error ignoring, poor naming, and unsafe goroutine management.

  • Enforce explicit error handling with fmt.Errorf wrapping and errors.Is/As checking
  • Apply idiomatic naming: short vars, no stuttering, acronym casing, -er suffix for interfaces
  • Require context.Context as first parameter for blocking functions with proper defer cancel()
  • Mandate table-driven tests and interface-based mocking patterns
  • Prevent forbidden patterns: ignored errors, init() for logic, global mutable state, unsafe goroutines

Applies to

File patterns this rule matches.

**/*.go
Rule definition (reference)

Source of truth, from the repository.

Go Language Rules

Expert Go developer. Simple, explicit, idiomatic.

Error Handling

  • Always handle errors — never assign to _
  • fmt.Errorf("context: %w", err) for wrapping
  • errors.Is() / errors.As() for checking
  • Custom error types for structured errors

Naming

  • Short for short-lived vars: i, n, err, ok
  • No stuttering: user.UserID → user.ID
  • Acronyms: userID, httpClient (not userId, httpClient)
  • Interfaces: end in -er (Reader, Writer, Handler)

Interfaces

  • Accept interfaces, return concrete types
  • Define at call site, not implementation site
  • Single-method interfaces preferred

Concurrency

  • context.Context first param for blocking functions
  • defer cancel() after context creation
  • WaitGroup for goroutine groups
  • Channels for communication, Mutex for state

Testing

  • Table-driven: for _, tc := range testCases { t.Run(tc.name, ...) }
  • Interface-based mocking

Forbidden

  • No _ to ignore errors
  • No init() for business logic
  • No global mutable state
  • No interface{} where generics work
  • No goroutines without termination condition

Related rules

Senior full-stack TypeScript, React, Node.js guidance with clean architecture, testing, and WHY-oriented reasoning.

**/*
41k
via PatrickJS/awesome-cursorrules

Quantitative factor research skills for designing, evaluating, and mining alpha factors in equities markets.

**/*
41k
via PatrickJS/awesome-cursorrules

Android development with Jetpack Compose, clean architecture, and Material Design 3.

**/*
41k
via PatrickJS/awesome-cursorrules

Angular development with Novo Elements UI library using standalone components.

**/*
41k
via PatrickJS/awesome-cursorrules

Expert Angular 18 + TypeScript development with Jest, emphasizing clean code and performance.

**/*
41k
via PatrickJS/awesome-cursorrules

Manage Kubernetes clusters, add-ons, stacks, and credentials via the Ankra CLI platform.

**/*.sh +5
41k
via PatrickJS/awesome-cursorrules