tag:github.com,2008:https://github.com/mpyw/feature/releases Release notes from feature 2025-12-14T06:12:02Z tag:github.com,2008:Repository/1114554914/v0.4.0 2025-12-14T06:22:47Z v0.4.0 <h2>Installation</h2> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="go get github.com/mpyw/feature@v0.4.0"><pre>go get github.com/mpyw/feature@v0.4.0</pre></div> <h2>What's Changed</h2> <ul> <li>Reimplement GoString for keys with functional option format by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mpyw/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mpyw">@mpyw</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3726822822" data-permission-text="Title is private" data-url="https://github.com/mpyw/feature/issues/3" data-hovercard-type="pull_request" data-hovercard-url="/mpyw/feature/pull/3/hovercard" href="https://github.com/mpyw/feature/pull/3">#3</a></li> </ul> <blockquote> <h2>Summary</h2> <ul> <li>Remove <code>GoString</code> from <code>Inspection</code> and <code>BoolInspection</code></li> <li>Reimplement <code>GoString</code> for <code>key[V]</code> and <code>boolKey</code> to output valid Go expressions with functional option format <ul> <li><code>feature.New[string](feature.WithName("key-name"))</code></li> <li><code>feature.NewBool(feature.WithName("flag-name"))</code></li> </ul> </li> <li>Update README with background on Go official proposal (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1037731122" data-permission-text="Title is private" data-url="https://github.com/golang/go/issues/49189" data-hovercard-type="issue" data-hovercard-url="/golang/go/issues/49189/hovercard" href="https://github.com/golang/go/issues/49189">golang/go#49189</a>) and design decisions (Sealed Interface pattern, empty struct optimization avoidance)</li> </ul> </blockquote> <p><strong>Full Changelog</strong>: <a class="commit-link" href="https://github.com/mpyw/feature/compare/v0.3.0...v0.4.0"><tt>v0.3.0...v0.4.0</tt></a></p> mpyw tag:github.com,2008:Repository/1114554914/v0.3.0 2025-12-12T06:20:04Z v0.3.0 <h2>Installation</h2> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="go get github.com/mpyw/feature@v0.3.0"><pre>go get github.com/mpyw/feature@v0.3.0</pre></div> <h2>What's Changed</h2> <ul> <li>Add Inspection pattern for ergonomic value retrieval by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mpyw/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mpyw">@mpyw</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3722143269" data-permission-text="Title is private" data-url="https://github.com/mpyw/feature/issues/2" data-hovercard-type="pull_request" data-hovercard-url="/mpyw/feature/pull/2/hovercard" href="https://github.com/mpyw/feature/pull/2">#2</a></li> </ul> <blockquote> <h2>Summary</h2> <p>This PR introduces a new <strong>Inspection pattern</strong> that separates context value retrieval from display logic, providing a more ergonomic and flexible API for working with feature flag values.</p> <h3>Key Changes</h3> <ul> <li> <p><strong>New <code>Inspection[V]</code> struct</strong>: Captures the key, value, and whether it was set in a single call to <code>Inspect(ctx)</code>. All helper methods (<code>Get</code>, <code>TryGet</code>, <code>GetOrDefault</code>, <code>MustGet</code>, <code>IsSet</code>, <code>IsNotSet</code>) are now available on the inspection result without needing to pass context again.</p> </li> <li> <p><strong>New <code>BoolInspection</code> struct</strong>: A specialized wrapper for boolean feature flags with <code>Enabled()</code>, <code>Disabled()</code>, and <code>ExplicitlyDisabled()</code> convenience methods.</p> </li> <li> <p><strong><code>fmt.Stringer</code> and <code>fmt.GoStringer</code> support</strong>: Both <code>Key</code> and <code>Inspection</code> types now implement these interfaces with package-qualified output for better debugging.</p> </li> <li> <p><strong>Breaking change</strong>: Removed <code>DebugValue</code>/<code>DebugString</code> methods (replaced by <code>Inspection.String()</code>).</p> </li> </ul> <h2>Example Usage</h2> <div class="highlight highlight-source-go notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="var MaxRetries = feature.NewNamed[int](&quot;max-retries&quot;) // Inspect returns both the value and whether it was set inspection := MaxRetries.Inspect(ctx) fmt.Println(inspection) // &quot;max-retries: 5&quot; or &quot;max-retries: &lt;not set&gt;&quot; fmt.Println(inspection.IsSet()) // true or false // All helper methods available without context value := inspection.GetOrDefault(3)"><pre><span class="pl-k">var</span> <span class="pl-s1">MaxRetries</span> <span class="pl-c1">=</span> feature.<span class="pl-smi">NewNamed</span>[<span class="pl-smi">int</span>](<span class="pl-s">"max-retries"</span>) <span class="pl-c">// Inspect returns both the value and whether it was set</span> <span class="pl-s1">inspection</span> <span class="pl-c1">:=</span> <span class="pl-s1">MaxRetries</span>.<span class="pl-c1">Inspect</span>(<span class="pl-s1">ctx</span>) <span class="pl-s1">fmt</span>.<span class="pl-c1">Println</span>(<span class="pl-s1">inspection</span>) <span class="pl-c">// "max-retries: 5" or "max-retries: &lt;not set&gt;"</span> <span class="pl-s1">fmt</span>.<span class="pl-c1">Println</span>(<span class="pl-s1">inspection</span>.<span class="pl-c1">IsSet</span>()) <span class="pl-c">// true or false</span> <span class="pl-c">// All helper methods available without context</span> <span class="pl-s1">value</span> <span class="pl-c1">:=</span> <span class="pl-s1">inspection</span>.<span class="pl-c1">GetOrDefault</span>(<span class="pl-c1">3</span>)</pre></div> <h2>File Changes</h2> <table> <thead> <tr> <th>File</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>feature.go</code></td> <td>Added <code>Inspect()</code> method to <code>Key[V]</code>, <code>InspectBool()</code> to <code>BoolKey</code>, <code>fmt.GoStringer</code> interface, refactored existing methods to use Inspection internally</td> </tr> <tr> <td><code>inspection.go</code></td> <td>New file containing <code>Inspection[V]</code> and <code>BoolInspection</code> structs with all helper methods</td> </tr> <tr> <td><code>feature_test.go</code></td> <td>Updated tests, removed obsolete <code>DebugValue</code> tests</td> </tr> <tr> <td><code>inspection_test.go</code></td> <td>New comprehensive tests for Inspection functionality</td> </tr> </tbody> </table> </blockquote> <p><strong>Full Changelog</strong>: <a class="commit-link" href="https://github.com/mpyw/feature/compare/v0.2.0...v0.3.0"><tt>v0.2.0...v0.3.0</tt></a></p> mpyw tag:github.com,2008:Repository/1114554914/v0.2.0 2025-12-12T01:05:41Z v0.2.0 <h2>Installation</h2> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="go get github.com/mpyw/feature@v0.2.0"><pre>go get github.com/mpyw/feature@v0.2.0</pre></div> <h2>What's Changed</h2> <ul> <li>Remove and enhance anonymous key debugging by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mpyw/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mpyw">@mpyw</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3721459300" data-permission-text="Title is private" data-url="https://github.com/mpyw/feature/issues/1" data-hovercard-type="pull_request" data-hovercard-url="/mpyw/feature/pull/1/hovercard" href="https://github.com/mpyw/feature/pull/1">#1</a></li> </ul> <blockquote> <h2>Breaking Changes</h2> <table> <thead> <tr> <th>Removed</th> <th>Reason</th> </tr> </thead> <tbody> <tr> <td>option</td> <td>Redundant (named keys are sufficient, anonymous keys now auto-include debug info)</td> </tr> <tr> <td>type</td> <td>No longer needed after removal</td> </tr> </tbody> </table> <h2>Enhancements</h2> <h3>Automatic Debug Info for Anonymous Keys</h3> <p>Keys created without a name now automatically include their definition location (file path and line number).</p> <p>This allows you to quickly identify where a key was defined, even if you forgot to name it.</p> <h2>Changes</h2> <ul> <li>Use to capture call site information</li> <li>Add for accurate stack depth tracking</li> <li>Update doc comments and README with new format documentation</li> <li>Extract anonymous key tests to (ensures stable line numbers)</li> </ul> </blockquote> <p><strong>Full Changelog</strong>: <a class="commit-link" href="https://github.com/mpyw/feature/compare/v0.1.0...v0.2.0"><tt>v0.1.0...v0.2.0</tt></a></p> mpyw tag:github.com,2008:Repository/1114554914/v0.1.0 2025-12-11T18:08:25Z v0.1.0 <h2>Installation</h2> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="go get github.com/mpyw/feature@v0.1.0"><pre>go get github.com/mpyw/feature@v0.1.0</pre></div> <h2>What's Changed</h2> <p>Initial Commit</p> <p><strong>Full Changelog</strong>: <a href="https://github.com/mpyw/feature/commits/v0.1.0">https://github.com/mpyw/feature/commits/v0.1.0</a></p> mpyw