1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 09:57:01 +00:00

introduce iris.NewGuide()

This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-06-05 22:12:57 +03:00
parent d8af2a1e14
commit 288a67bc58
7 changed files with 597 additions and 13 deletions

View File

@@ -157,7 +157,16 @@ func fromFunc(v reflect.Value, dest *Dependency) bool {
numOut := typ.NumOut()
if numIn == 0 {
panic("bad value: function has zero inputs")
// it's an empty function, that must return a structure.
if numOut != 1 {
firstOutType := indirectType(typ.Out(0))
if firstOutType.Kind() != reflect.Struct && firstOutType.Kind() != reflect.Interface {
panic(fmt.Sprintf("bad value: function has zero inputs: empty input function must output a single value but got: length=%v, type[0]=%s", numOut, firstOutType.String()))
}
}
// fallback to structure.
return fromStructValue(v.Call(nil)[0], dest)
}
if numOut == 0 {