karlkfi / inject

Dependency injection library for Go (golang)
Apache License 2.0
80 stars 7 forks source link

Panic if using slice arguments #8

Closed hori-ryota closed 5 years ago

hori-ryota commented 7 years ago

If using slice arguments in constructor, following panic messages.

panic: arg 1 of type "[]uint" cannot be assigned or converted to type "uint" for provider constructor ...

This error cause following code for variadic methods in provider.go

        if i < fnType.NumIn() {
            inType = fnType.In(i)
        } else {
            inType = fnType.In(fnType.NumIn() - 1)
        }

        if inType.Kind() == reflect.Slice {
            inType = inType.Elem()
        }