Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge change for issue #224 #245

Merged
merged 5 commits into from
Dec 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions support/ref.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package support

import "reflect"
import (
"reflect"
"strings"
)

func GetRef(contrib interface{}) string {
v := reflect.ValueOf(contrib)
Expand All @@ -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
}