Skip to content

Conversation

@mpyw
Copy link
Owner

@mpyw mpyw commented Dec 12, 2025

Preparation for v0.2.0 release. Removes redundant functionality and enhances anonymous key debugging experience.

Breaking Changes

Removed Reason
WithStringer option Redundant (named keys are sufficient, anonymous keys now auto-include debug info)
StringerFunc type No longer needed after WithStringer removal

Enhancements

Automatic Debug Info for Anonymous Keys

Keys created without a name now automatically include their definition location (file path and line number).

// Before (v0.1.x)
var Flag = feature.NewBool()
fmt.Println(Flag) // anonymous@0x14000010098

// After (v0.2.0)
var Flag = feature.NewBool()
fmt.Println(Flag) // anonymous(/path/to/file.go:42)@0x14000010098

This allows you to quickly identify where a key was defined, even if you forgot to name it.

Changes

  • Use runtime.Caller to capture call site information
  • Add appendCallerDepthIncr for accurate stack depth tracking
  • Update doc comments and README with new format documentation
  • Extract anonymous key tests to anonymous_test.go (ensures stable line numbers)

Test Plan

  • go test -v -race all pass
  • go vet ./... no issues
  • All Example tests work correctly"

@codecov
Copy link

codecov bot commented Dec 12, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@mpyw mpyw changed the title feat!: remove WithStringer and enhance anonymous key debugging Remove WithStringer and enhance anonymous key debugging Dec 12, 2025
@mpyw mpyw changed the title Remove WithStringer and enhance anonymous key debugging Remove WithStringer and enhance anonymous key debugging Dec 12, 2025
BREAKING CHANGES:
- Remove WithStringer option and StringerFunc type

The WithStringer option was redundant since named keys already provide
clear identification, and anonymous keys now include call site info.

Enhancements:
- Anonymous keys now include file path and line number in their name
  (e.g., "anonymous(/path/to/file.go:42)@0x...")
- Add runtime.Caller integration with depth tracking for accurate
  call site resolution across New, NewBool, NewNamed, NewNamedBool

Other changes:
- Extract anonymous key tests to anonymous_test.go for stable line numbers
- Update doc comments and README with new anonymous key format
@mpyw mpyw merged commit f138f17 into main Dec 12, 2025
12 checks passed
@mpyw mpyw deleted the release-v0.2.0 branch December 12, 2025 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants