From 82972d8097c8bb82ee687adb263fb6cf63e46449 Mon Sep 17 00:00:00 2001 From: Yueming Xu Date: Thu, 10 Dec 2020 10:04:24 -0700 Subject: [PATCH] merge change for issue #224 (#245) * Resulve issue #224 GetRef() in support package should remove 'vendor' path * Resulve issue #224 GetRef() in support package should remove 'vendor' path allows trigger developer to pass request parameters to handler w/o going through output mapper * resubmit pull request to resolve issue #224 --- support/ref.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/support/ref.go b/support/ref.go index 43c948cd..e54f324d 100644 --- a/support/ref.go +++ b/support/ref.go @@ -1,6 +1,9 @@ package support -import "reflect" +import ( + "reflect" + "strings" +) func GetRef(contrib interface{}) string { v := reflect.ValueOf(contrib) @@ -11,9 +14,18 @@ func GetRef(contrib interface{}) string { ref := v.Type().PkgPath() - return ref + return fixPkgPathVendoring(ref) } type HasRef interface { Ref() string } + +// fixes vendored paths +func fixPkgPathVendoring(pkgPath string) string { + const vendor = "/vendor/" + if i := strings.LastIndex(pkgPath, vendor); i != -1 { + return pkgPath[i+len(vendor):] + } + return pkgPath +}