Releases: mpyw/feature
v0.4.0
Installation
go get github.com/mpyw/feature@v0.4.0What's Changed
Summary
- Remove
GoStringfromInspectionandBoolInspection- Reimplement
GoStringforkey[V]andboolKeyto output valid Go expressions with functional option format
feature.New[string](feature.WithName("key-name"))feature.NewBool(feature.WithName("flag-name"))- Update README with background on Go official proposal (golang/go#49189) and design decisions (Sealed Interface pattern, empty struct optimization avoidance)
Full Changelog: v0.3.0...v0.4.0
v0.3.0
Installation
go get github.com/mpyw/feature@v0.3.0What's Changed
Summary
This PR introduces a new Inspection pattern that separates context value retrieval from display logic, providing a more ergonomic and flexible API for working with feature flag values.
Key Changes
New
Inspection[V]struct: Captures the key, value, and whether it was set in a single call toInspect(ctx). All helper methods (Get,TryGet,GetOrDefault,MustGet,IsSet,IsNotSet) are now available on the inspection result without needing to pass context again.New
BoolInspectionstruct: A specialized wrapper for boolean feature flags withEnabled(),Disabled(), andExplicitlyDisabled()convenience methods.
fmt.Stringerandfmt.GoStringersupport: BothKeyandInspectiontypes now implement these interfaces with package-qualified output for better debugging.Breaking change: Removed
DebugValue/DebugStringmethods (replaced byInspection.String()).Example Usage
var MaxRetries = feature.NewNamed[int]("max-retries") // Inspect returns both the value and whether it was set inspection := MaxRetries.Inspect(ctx) fmt.Println(inspection) // "max-retries: 5" or "max-retries: <not set>" fmt.Println(inspection.IsSet()) // true or false // All helper methods available without context value := inspection.GetOrDefault(3)File Changes
File Description feature.goAdded Inspect()method toKey[V],InspectBool()toBoolKey,fmt.GoStringerinterface, refactored existing methods to use Inspection internallyinspection.goNew file containing Inspection[V]andBoolInspectionstructs with all helper methodsfeature_test.goUpdated tests, removed obsolete DebugValuetestsinspection_test.goNew comprehensive tests for Inspection functionality
Full Changelog: v0.2.0...v0.3.0
v0.2.0
Installation
go get github.com/mpyw/feature@v0.2.0What's Changed
Breaking Changes
Removed Reason option Redundant (named keys are sufficient, anonymous keys now auto-include debug info) type No longer needed after removal Enhancements
Automatic Debug Info for Anonymous Keys
Keys created without a name now automatically include their definition location (file path and line number).
This allows you to quickly identify where a key was defined, even if you forgot to name it.
Changes
- Use to capture call site information
- Add for accurate stack depth tracking
- Update doc comments and README with new format documentation
- Extract anonymous key tests to (ensures stable line numbers)
Full Changelog: v0.1.0...v0.2.0
v0.1.0
Installation
go get github.com/mpyw/feature@v0.1.0What's Changed
Initial Commit
Full Changelog: https://github.com/mpyw/feature/commits/v0.1.0