Skip to content

Releases: mpyw/feature

v0.4.0

14 Dec 06:20
13a0bcf

Choose a tag to compare

Installation

go get github.com/mpyw/feature@v0.4.0

What's Changed

  • Reimplement GoString for keys with functional option format by @mpyw in #3

Summary

  • Remove GoString from Inspection and BoolInspection
  • Reimplement GoString for key[V] and boolKey to 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

12 Dec 06:18
375ee78

Choose a tag to compare

Installation

go get github.com/mpyw/feature@v0.3.0

What's Changed

  • Add Inspection pattern for ergonomic value retrieval by @mpyw in #2

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 to Inspect(ctx). All helper methods (Get, TryGet, GetOrDefault, MustGet, IsSet, IsNotSet) are now available on the inspection result without needing to pass context again.

  • New BoolInspection struct: A specialized wrapper for boolean feature flags with Enabled(), Disabled(), and ExplicitlyDisabled() convenience methods.

  • fmt.Stringer and fmt.GoStringer support: Both Key and Inspection types now implement these interfaces with package-qualified output for better debugging.

  • Breaking change: Removed DebugValue/DebugString methods (replaced by Inspection.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.go Added Inspect() method to Key[V], InspectBool() to BoolKey, fmt.GoStringer interface, refactored existing methods to use Inspection internally
inspection.go New file containing Inspection[V] and BoolInspection structs with all helper methods
feature_test.go Updated tests, removed obsolete DebugValue tests
inspection_test.go New comprehensive tests for Inspection functionality

Full Changelog: v0.2.0...v0.3.0

v0.2.0

12 Dec 00:56
f138f17

Choose a tag to compare

Installation

go get github.com/mpyw/feature@v0.2.0

What's Changed

  • Remove and enhance anonymous key debugging by @mpyw in #1

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

11 Dec 18:07
b1c56c1

Choose a tag to compare

Installation

go get github.com/mpyw/feature@v0.1.0

What's Changed

Initial Commit

Full Changelog: https://github.com/mpyw/feature/commits/v0.1.0