Goenums: Type Safe Enum Generator for Go
Published on: 2025-08-07 03:26:59
goenums
goenums addresses Go's lack of native enum support by generating comprehensive, type-safe enum implementations from simple constant declarations. Transform basic iota based constants into feature-rich enums with string conversion, validation, JSON handling, database integration, and more.
Installation
go install github.com/zarldev/goenums@latest
Documentation
Documentation is available at https://zarldev.github.io/goenums.
Table of Contents
Key Features
Type Safety: Wrapper types prevent accidental misuse of enum values
String Conversion: Automatic string representation and parsing
JSON Support: Built-in marshaling and unmarshaling
Database Integration: SQL Scanner and Valuer implementations
Validation: Methods to check for valid enum values
Iteration: Modern Go 1.21+ iteration support with legacy fallback
Extensibility: Add custom fields to enums via comments
Exhaustive Handling: Helper functions to ensure you handle all enum values
Zero Dependencies: Completel
... Read full article.