Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"permissions": {
"allow": [
"WebFetch(domain:github.com)",
"Bash(gh issue view:*)",
"Bash(go test:*)",
"Bash(go run:*)",
"Bash(go mod why:*)",
"Bash(go list:*)",
"Read(//Users/qjeremy/go/pkg/mod/github.com/jquirke/[email protected]/**)",
"Read(//Users/qjeremy/github/jquirke/**)",
"Bash(git checkout:*)",
"Bash(sed:*)",
"Bash(go vet:*)"
],
"deny": [],
"ask": []
}
}
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
- No changes yet.

### Added
- Support for map value groups consumption via `map[string]T` for named value groups,
enabling both individual named access and map-based access to the same providers.
- Comprehensive test coverage for map value groups functionality including decoration,
edge cases, and validation of slice decorator restrictions.

## [1.24.0](https://github.com/uber-go/fx/compare/v1.23.0...v1.24.0) - 2025-05-13

Expand Down
6 changes: 4 additions & 2 deletions annotated.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ type Annotated struct {
// by the constructor. For more information on named values, see the documentation
// for the fx.Out type.
//
// A name option may not be provided if a group option is provided.
// Name can be used together with Group to create named value groups that can be
// consumed both individually by name and collectively as a map.
Name string

// If specified, this will be used as the group name for all non-error values returned
// by the constructor. For more information on value groups, see the package documentation.
//
// A group option may not be provided if a name option is provided.
// Group can be used together with Name to create named value groups that can be
// consumed both individually by name and collectively as a map or slice.
//
// Similar to group tags, the group name may be followed by a `,flatten`
// option to indicate that each element in the slice returned by the
Expand Down
30 changes: 30 additions & 0 deletions annotated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,36 @@ func TestAnnotate(t *testing.T) {
require.NoError(t, app.Err())
})

t.Run("Invoke function with soft map group param", func(t *testing.T) {
t.Parallel()
newF := func(fooMap map[string]int, bar string) {
expected := map[string]int{"executed": 10}
assert.Equal(t, expected, fooMap)
assert.Equal(t, "hello", bar)
}
app := fxtest.New(t,
fx.Provide(
fx.Annotate(
func() (int, string) { return 10, "hello" },
fx.ResultTags(`name:"executed" group:"foos"`, ``),
),
fx.Annotate(
func() int {
require.FailNow(t, "this function should not be called")
return 20
},
fx.ResultTags(`name:"not_executed" group:"foos"`),
),
),
fx.Invoke(
fx.Annotate(newF, fx.ParamTags(`group:"foos,soft"`, ``)),
),
)

defer app.RequireStart().RequireStop()
require.NoError(t, app.Err())
})

t.Run("Invoke variadic function with multiple params", func(t *testing.T) {
t.Parallel()

Expand Down
Loading