Go + Gin Rules
Go web API with Gin framework and clean architecture
# Role You are an expert Go developer building REST APIs with Gin and following Go idioms. # Tech Stack - Go 1.23+ - Gin web framework - GORM - Viper (config) # Code Conventions - Follow standard Go project layout: cmd/, internal/, pkg/. - Handle errors explicitly. Always check returned errors. - Use interfaces for dependency injection and testability. - Return errors rather than panicking. - Use context.Context for cancellation and deadlines. - Group related types in the same package. - Use meaningful variable names. Short names only for small scopes. - Write table-driven tests. - Use struct tags for JSON serialization. # Code Style Preferences - Use TypeScript strict mode. Define types for all variables, parameters, and return values. - Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it. - Use `const` by default. Only use `let` when reassignment is needed. Never use `var`. - Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors. - Use early returns (guard clauses) to reduce nesting and improve readability. - Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations. - Keep functions small and focused. Each function should do one thing. Aim for under 50 lines. # What to Avoid - Do not use `panic()` for normal error handling. - Do not ignore returned errors. - Do not use global mutable state. - Do not write overly long functions. Keep them focused. - Do not use `init()` functions unless absolutely necessary.
About Go + Gin AI Rules
AI coding rules files help your AI assistant (Cursor, Windsurf, Claude Code, GitHub Copilot, or Cline) understand your project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for Gin.
This preset is designed for Go + Gin projects and includes rules for:
- Follow standard Go project layout: cmd/, internal/, pkg/.
- Handle errors explicitly. Always check returned errors.
- Use interfaces for dependency injection and testability.
- Return errors rather than panicking.
- Use context.Context for cancellation and deadlines.
Simply select your preferred AI IDE format above, then copy or download the generated rules file. Place it in your project's root directory and your AI assistant will automatically follow these conventions.
Get This Preset for a Specific IDE
Cursor
Go + Gin rules for Cursor
Windsurf
Go + Gin rules for Windsurf
Claude Code
Go + Gin rules for Claude Code
GitHub Copilot
Go + Gin rules for GitHub Copilot
Cline
Go + Gin rules for Cline
Zed AI
Go + Gin rules for Zed AI
Aider
Go + Gin rules for Aider
Continue.dev
Go + Gin rules for Continue.dev
Devin AI
Go + Gin rules for Devin AI
Amazon Q
Go + Gin rules for Amazon Q
Bolt.new
Go + Gin rules for Bolt.new
Lovable
Go + Gin rules for Lovable
Replit AI
Go + Gin rules for Replit AI
Augment Code
Go + Gin rules for Augment Code
JetBrains AI
Go + Gin rules for JetBrains AI