Tags: go-pkgz/enum
Tags
add alias support for enum parsing (#17) allows enum constants to have comment annotations like // enum:alias=rw,read-write that enable parsing multiple string representations for the same enum value. - add parseAliasComment() to extract aliases from inline comments - add validateAliases() to check for conflicts and duplicates - update template to include aliases in parse map - make parsing always case-insensitive (fixes lowercase mode bug) - add comprehensive tests for alias feature - update README with alias documentation
Release v0.4.0
Performance Improvements:
- O(1) map-based parsing replacing switch statements (10x faster)
- Pre-computed Values and Names as package variables instead of functions
- Single shared enum instances to reduce memory allocation
New Features:
- SQL support with driver.Valuer and sql.Scanner interfaces
- Smart SQL NULL handling (uses zero value when available, errors otherwise)
- Index() method for accessing underlying integer values
- -getter flag for generating GetTypeByID functions (with validation for unique values)
- -lower flag for lowercase string representation in marshaling
- Preserve underlying type information (uint8, int32, etc.) in generated code
Improvements:
- Preserve source declaration order (was alphabetical before)
- Character literal support ('A', '\n', '\x00', etc.)
- Enhanced error messages with specific invalid value reporting
- Better binary expression handling with iota operations
- Fixed iota increment bug (now increments per ValueSpec as Go spec requires)
- Proper handling of underscore placeholders in const blocks
- Better edge case handling (division by zero, empty blocks)
Testing & Quality:
- Test coverage improved from 90.5% to 99.6%
- Comprehensive test suite for all new features
- Updated documentation with SQL examples and feature descriptions
PreviousNext