Support variadic provider and injector functions (#91)

Fixes #61
This commit is contained in:
shantuo
2018-12-03 08:30:42 -08:00
committed by Ross Light
parent 65d810f60a
commit ef9bb67152
8 changed files with 100 additions and 4 deletions

View File

@@ -153,6 +153,9 @@ type Provider struct {
// Args is the list of data dependencies this provider has.
Args []ProviderInput
// Varargs is true if the provider function is variadic.
Varargs bool
// IsStruct is true if this provider is a named struct type.
// Otherwise it's a function.
IsStruct bool
@@ -639,6 +642,7 @@ func processFuncProvider(fset *token.FileSet, fn *types.Func) (*Provider, []erro
Name: fn.Name(),
Pos: fn.Pos(),
Args: make([]ProviderInput, params.Len()),
Varargs: sig.Variadic(),
Out: []types.Type{providerSig.out},
HasCleanup: providerSig.cleanup,
HasErr: providerSig.err,