🐹

Amazon Q Rules for Go + Gin

Go web API with Gin framework and clean architecture

GoGinRESTClean Arch
.amazonq/rules
# 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 Amazon Q Rules for Go + Gin

The .amazonq/rules file helps Amazon Q understand your Go + Gin 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 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.

How to use this file

  1. Click Copy or Download above.
  2. Place the .amazonq/rules file in your project's root directory.
  3. Amazon Q will automatically detect and apply these rules.

Get Go + Gin Rules for Other IDEs

Other Amazon Q Presets