Skip to content

Commit 82972d8

Browse files
authored
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
1 parent 7abcfcc commit 82972d8

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

support/ref.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package support
22

3-
import "reflect"
3+
import (
4+
"reflect"
5+
"strings"
6+
)
47

58
func GetRef(contrib interface{}) string {
69
v := reflect.ValueOf(contrib)
@@ -11,9 +14,18 @@ func GetRef(contrib interface{}) string {
1114

1215
ref := v.Type().PkgPath()
1316

14-
return ref
17+
return fixPkgPathVendoring(ref)
1518
}
1619

1720
type HasRef interface {
1821
Ref() string
1922
}
23+
24+
// fixes vendored paths
25+
func fixPkgPathVendoring(pkgPath string) string {
26+
const vendor = "/vendor/"
27+
if i := strings.LastIndex(pkgPath, vendor); i != -1 {
28+
return pkgPath[i+len(vendor):]
29+
}
30+
return pkgPath
31+
}

0 commit comments

Comments
 (0)