enum-go

Create typed domain enums in Go with constants, validation helpers, and doc-comment conventions.

4|Updated Jul 30, 2026
One-click install
npx skills add https://github.com/gabriellst/codm --skill enum-go-gabriellst
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: enum-go
Source: https://github.com/gabriellst/codm/tree/main/.claude/skills/enum/go
Command: npx skills add https://github.com/gabriellst/codm --skill enum-go-gabriellst

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Go has no native enum keyword, so teams often end up with inconsistent string constants, untyped fields, and invalid values leaking into the domain. This Skill standardizes how closed vocabularies like JobStatus or MessageType are declared, validated, and consumed across entities, repositories, and controllers. ## Core Features & Use Cases - Idiomatic enum scaffolding: Generates a named string type, a typed const block with SCREAMING_SNAKE_CASE wire values, and a // Values: doc-comment consumed by OpenAPI tooling. - Runtime validation: Adds an IsValid() helper and Values() member list so controllers and repositories can guard enum values arriving from HTTP bodies, query params, or DB columns. - Convention enforcement: Encodes rules like one enum per file, typed struct fields instead of plain strings, and status transitions as guard conditions in entity behavior methods. - Use Case: When adding a new ChannelStatus to a Go bounded context, use this Skill to produce the enum file, wire it into the entity, and validate external input before constructing domain objects. ## Quick Start Create a Go domain enum for message delivery status with PENDING, SENT, and FAILED values, including an IsValid helper.

Frequently Asked Questions about enum-go

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

FAQPage Schema
How do I create an enum in Go?

Declare a named string type like `type JobStatus string` and a const block of typed constants such as `JobStatusPending JobStatus = "PENDING"`. Add a `// Values:` doc-comment line and an optional IsValid method for runtime validation of external input.

How to validate enum values from HTTP requests in Go?

Cast the raw string to the enum type, then call its IsValid method before constructing any entity. If validation fails, return a domain error instead of letting an invalid value enter the domain layer.

Should Go enum constants use lowercase or uppercase string values?

Wire values stored in the database and sent over the wire should be SCREAMING_SNAKE_CASE, while the Go constant identifier uses PascalCase prefixed with the type name. Lowercase values break DB constraints and OpenAPI enum schemas.

When should I not use a string-based enum in Go?

Avoid this pattern for open-ended string fields with no fixed value set, and for flags or bitmasks where iota with bit-shifting is more idiomatic. Values already defined in a shared contracts package should be imported rather than re-declared.

Why use a named enum type instead of plain string struct fields?

A named type gives compile-time protection, so assigning an arbitrary string to a Status field becomes a compile error instead of a runtime bug. It also enables IDE autocomplete and a single definition shared by entities, repositories, and controllers.