go-declarations

Rewrite Go declarations to prevent shadowing and nil map panics.

8|Updated Jun 5, 2026
One-click install
npx skills add https://github.com/muratmirgun/gophers --skill go-declarations
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-declarations
Source: https://github.com/muratmirgun/gophers/tree/main/skills/go-declarations
Command: npx skills add https://github.com/muratmirgun/gophers --skill go-declarations

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you choose the right Go declaration and initialization style so your code stays clear, idiomatic, and safe from subtle bugs like shadowing, nil map writes, and misleading zero values.

Core Features & Use Cases

  • Declaration Style Guidance: Chooses between var and := based on scope, intent, and zero-value semantics.
  • Idiomatic Initialization: Recommends field-named struct literals, make for writable maps, raw strings for regex or SQL, and any instead of interface{}.
  • Safety Checks: Avoids shadowed builtins and enum mistakes such as zero-valued iota collisions.
  • Use Case: When drafting a new config struct, const block, or helper function, this Skill can rewrite the declarations to follow Go best practices and a consistent project style.

Quick Start

Ask the skill to review your Go declarations and rewrite them using idiomatic var, :=, iota, struct literal, and map initialization patterns.

Frequently Asked Questions about go-declarations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent nil map panics when initializing maps in Go?

To prevent nil map panics in Go, initialize maps using the make function before writing to them. This Skill automatically rewrites map declarations to ensure writable maps are safely allocated and avoids runtime panics on nil map writes.

What is the best way to declare Go structs and constants to avoid shadowing?

The best way to avoid shadowing in Go is to use scope-aware variable declarations and field-named struct literals. This Skill analyzes your code and rewrites declaration blocks to prevent shadowed builtins and zero-valued iota enum collisions.

How do I choose between var and := for Go variable declarations?

Choosing between var and := in Go depends on scope, intent, and zero-value semantics. This Skill evaluates your variable declarations and applies the idiomatic initialization style that clarifies intent and prevents misleading zero values.

When should I use the any type instead of interface{} in Go code?

You should use the any type instead of interface{} in Go code to satisfy modern idiomatic requirements. This Skill reviews your declarations and updates type usage to align your production code with current Go best practices.

Can I use this to review and rewrite existing Go declaration blocks?

Yes, you can use this to review and rewrite existing Go declaration blocks. It optimizes variable declarations, constants, structs, maps, and raw string literals in production Go code and code review workflows to follow consistent project style.