Skip to content

Commit

Permalink
Resulve issue project-flogo#224 GetRef() in support package should re…
Browse files Browse the repository at this point in the history
…move 'vendor' path
  • Loading branch information
yxuco committed Oct 8, 2020
1 parent 202a27f commit cf81f70
Showing 1 changed file with 14 additions and 2 deletions.
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
}

0 comments on commit cf81f70

Please sign in to comment.