Fix a bug in framework.IgnoreNotFound where it will panic when a function type's final input parameter is a "..." parameter.

This commit is contained in:
carlory 2024-11-14 16:44:04 +08:00
parent 475ee33f69
commit cd6f4153e0

View File

@ -97,7 +97,12 @@ func IgnoreNotFound(in any) any {
inType := reflect.TypeOf(in)
inValue := reflect.ValueOf(in)
return reflect.MakeFunc(inType, func(args []reflect.Value) []reflect.Value {
out := inValue.Call(args)
var out []reflect.Value
if inType.IsVariadic() {
out = inValue.CallSlice(args)
} else {
out = inValue.Call(args)
}
if len(out) > 0 {
lastValue := out[len(out)-1]
last := lastValue.Interface()