golang-naming

Enforce idiomatic Go naming conventions for identifiers, booleans, acronyms, constructors, and enums.

Updated Oct 1, 2024
One-click install
npx skills add https://github.com/mrlorentx/.files --skill golang-naming-mrlorentx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-naming
Source: https://github.com/mrlorentx/.files/tree/main/ai/claude/skills/golang-naming
Command: npx skills add https://github.com/mrlorentx/.files --skill golang-naming-mrlorentx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go projects often struggle with inconsistent naming, leading to reduced readability and increased maintenance burden. This skill provides a cohesive set of Go naming rules to unify identifiers across packages, improve code searchability, and align with community conventions.

Core Features & Use Cases

  • MixedCaps naming for packages, types, and variables to improve readability.
  • Boolean predicates use Is/Has/Can prefixes to clearly express state.
  • Acronym handling: use all caps (URL, HTTP) or all lower in identifiers; ensure consistent casing.
  • Constructor naming: use New for single-type packages and NewTypeName for multiple types.
  • Enum patterns with iota: protect zero value, or use explicit Unknown sentinel.
  • Test naming: avoid stuttering and use descriptive, consistent names.

Quick Start

Review your Go codebase and rename identifiers to MixedCaps, prefix booleans with Is/Has/Can, standardize acronyms, and apply constructor and enum guidelines.

Frequently Asked Questions about golang-naming

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

FAQPage Schema
What are the Go naming conventions for variables and types?

Go naming conventions require MixedCaps for variables, types, and packages to improve code readability and maintainability. This approach eliminates underscores and aligns with idiomatic community standards.

How do I name boolean variables and predicates in Go?

Boolean predicates in Go should use Is, Has, or Can prefixes to clearly express state and improve readability. This convention makes boolean variables immediately recognizable during code writing and reviewing.

What is the best way to handle acronyms when naming identifiers in Go?

The best way to handle Go acronyms in identifiers is to use consistent all caps or all lower casing, such as URL or HTTP. This ensures uniformity and improves code searchability across the codebase.

How do I name constructors and iota-based enums in Go?

Go constructors should use New for single-type packages and NewTypeName for multiple types. For iota-based enums, protect the zero value or use an explicit Unknown sentinel to prevent unhandled states.

Does this Go naming guidance apply to test file naming?

Yes, Go test naming guidelines recommend avoiding stuttering and using descriptive, consistent names. Applying these rules during refactoring ensures test functions remain clear and maintainable.