Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fx.Annotate: Variadic options should be optional #834

Closed
josephinedotlee opened this issue Feb 10, 2022 · 0 comments · Fixed by #831
Closed

fx.Annotate: Variadic options should be optional #834

josephinedotlee opened this issue Feb 10, 2022 · 0 comments · Fixed by #831
Assignees

Comments

@josephinedotlee
Copy link
Contributor

fx.Annotate allows passing a function that takes a variadic number of
arguments, and feeding them from a value group:

func NewFoo(...FooOption) *Foo

fx.Annotate(
  NewFoo,
  fx.ParamTags(`group:"option"`),
)

However, there's a bug: if you do not use the value group,
the parameter is a required []FooOption.

For example,

func NewFoo(...FooOption) *Foo

fx.Annotate(
  NewFoo,
  fx.As(new(Fooer)),
)

In this, the FooOptions should be optional as it is in fx outside of Annotate.

Whenever no tags are specified for a variadic parameter, it should be optional by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant