Skip to content

Fall back on reflection to select from slices#27

Open
theory wants to merge 2 commits intomainfrom
select-any-slice-or-map
Open

Fall back on reflection to select from slices#27
theory wants to merge 2 commits intomainfrom
select-any-slice-or-map

Conversation

@theory
Copy link
Copy Markdown
Owner

@theory theory commented Mar 28, 2026

Turns out to be more straightforward than I expected to support selecting values not just from []any and map[string]any but from any type of slice or string-keyed map, thanks to the reflect package.

Leave the branches for []any and map[string]any in place to avoid the overhead of reflection, but then use reflection if the value is any other type of slice or map. Resolves #26.

@theory theory self-assigned this Mar 28, 2026
@theory theory added the enhancement New feature or request label Mar 28, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1bef171) to head (6e9665f).

Additional details and impacted files
@@            Coverage Diff             @@
##              main       #27    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           15        15            
  Lines         1693      1895   +202     
==========================================
+ Hits          1693      1895   +202     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@theory theory force-pushed the select-any-slice-or-map branch 8 times, most recently from 2d49c4c to 85862f7 Compare March 29, 2026 23:04
theory added 2 commits March 29, 2026 19:28
Turns out to be more straightforward than I expected to support
selecting values not just from `[]any` and `map[string]any` but from any
type of slice or string-keyed map, thanks to the `reflect` package.

Leave the branches for `[]any` and `map[string]any` in place to avoid
the overhead of reflection, but then use reflection if the value is any
other type of slice or map. Resolves #26.
@theory theory force-pushed the select-any-slice-or-map branch from 0ed088b to 6e9665f Compare March 29, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Selector returns empty result on typed input

1 participant