Skip to content

Commit

Permalink
Fix vendor-ed imports issue
Browse files Browse the repository at this point in the history
  • Loading branch information
boxtown authored Feb 7, 2018
1 parent b3e60bc commit 7d90dd2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mockgen/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ func typeFromType(t reflect.Type) (Type, error) {
}

if imp := t.PkgPath(); imp != "" {
// PkgPath might return a path that includes "vendor"
// These paths do not compile, so we need to remove everything
// up to and including "/vendor/"
// see https://github.com/golang/go/issues/12019
if i := strings.LastIndex(imp, "/vendor/"); i != -1 {
imp = imp[i+len("/vendor/"):]
}
return &NamedType{
Package: imp,
Type: t.Name(),
Expand Down

0 comments on commit 7d90dd2

Please sign in to comment.