go-convention

Coding rules for generating Go code with consistent style, explicit error handling, and clean imports. Go is a programming language often used for services and command-line tools.

In plain words
What is it for?
Use them when creating or changing Go packages, types, errors, imports, file structure, and code that must pass tools such as gofmt and go vet.
Why use it?
They reduce common style, linting, and static-analysis problems while code is written in an IDE.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/freepeak/cortex/go-convention
Clone the repo
git clone --depth 1 https://github.com/FreePeak/cortex

Made for: Cursor.

Per session 1,270 This file is loaded in full into every session.
When invoked 1,270 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01270 $0.01270
Opus 5 $0.00635 $0.00635
Sonnet 5 $0.00254 $0.00254
Haiku 4.5 $0.00127 $0.00127

Measured yesterday against content hash f77c3f28aede, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

go-convention scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/go-convention.mdc · 114 lines

How it starts

The opening of the file, as written. The whole thing — 114 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Golang Guidelines

  • Follow the Go style guide (https://go.dev/doc/effective_go).
  • Use lowercase package names (e.g., http, utils).
  • Prefer explicit error handling with if err != nil over panics.
  • Use structs with exported fields (capitalized) for public APIs; lowercase for internal use.
  • Avoid unnecessary interfaces; only define them when multiple implementations are needed.
  • Use go fmt style: no unnecessary whitespace, consistent indentation.
  • Structure files: one main type/struct per file with related methods, helpers in separate utils files.
  • Naming: Short, concise, and contextual (e.g., db for database, srv for server).
  • Applying the Design Pattern when see the use case is fit with any design pattern.

Golang IDE Cursor Rules

These rules govern how the cursor behaves in your IDE to ensure that all generated Golang code passes linters (golint), static analysis (go vet), and can run without issues.

Automatic Imports

  1. Auto-import: When a new package is referenced, the cursor automatically adds the import to the top of the file
  2. Clean imports: When removing code that uses an import, the cursor automatically removes unused imports
  3. Group imports: Standard library imports are grouped first, followed by third-party libraries, then local packages
  4. Alphabetical order: Imports within each group are sorted alphabetically

Indentation and Formatting

  1. Tab-based indentation: Always use tabs (not spaces) for indentation
  2. Auto-format on save: Always run gofmt when saving a file
  3. Standard bracing: Opening braces always on the same line as the statement:
    if condition {
        // Code
    }
    
  4. Line length: Hard wrap at 100 characters

Variable and Function Naming

  1. camelCase for private: Private variables and functions use camelCase
  2. PascalCase for exported: Exported variables and functions use PascalCase
  3. Acronyms: Acronyms in names are all uppercase (e.g., HTTPServer not HttpServer)
  4. Short-lived variables: Use short names for variables with small scopes
  5. Descriptive names: Use descriptive names for exported functions and variables
  6. Context parameter: Name the context parameter ctx when present

Read the full file on GitHub · 114 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 114 lines · 1,270 tokens per session scan A f77c3f28aede

Subscribe to this mod's changes

go-convention is a cursor rule published in the GitHub repository FreePeak/cortex (25 stars, last pushed 1y ago), licensed Apache-2.0. It adds 1,270 tokens to every session, about $0.0064 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other cursor rules, from other repositories