From 0044123dbb9840d95a1df308230e78579630f663 Mon Sep 17 00:00:00 2001 From: Daniel Redondo Date: Wed, 22 Jan 2020 18:57:32 +0100 Subject: [PATCH] Added PatchMethodWithMakeFunc func --- patcher.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/patcher.go b/patcher.go index 218716c..0aae94e 100644 --- a/patcher.go +++ b/patcher.go @@ -65,6 +65,10 @@ func PatchMethodByReflect(target reflect.Method, redirection interface{}) (*Patc } return patch, nil } +func PatchMethodWithMakeFunc(target reflect.Method, fn func(args []reflect.Value) (results []reflect.Value)) (*Patch, error) { + rValue := reflect.MakeFunc(target.Type, fn) + return PatchMethodByReflect(target, rValue) +} func (p *Patch) Patch() error { if p == nil {