Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Fix a bug introduced in bdab667 that broke mocking interfaces with ve…
Browse files Browse the repository at this point in the history
…ndored dependencies in source mode.
  • Loading branch information
balshetzer committed Apr 4, 2018
1 parent c4148b8 commit 42764bf
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mockgen/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,13 @@ func importsOfFile(file *ast.File) map[string]string {
pkg, err := build.Import(importPath, "", 0)
if err != nil {
// Fallback to import path suffix. Note that this is uncertain.
log.Printf("failed to import package by path %s: %s - fallback to import path suffix", importPath, err.Error())
_, last := path.Split(importPath)
// If the last path component has dots, the first dot-delimited
// field is used as the name.
pkgName = strings.SplitN(last, ".", 2)[0]
} else {
pkgName = pkg.Name
}
pkgName = pkg.Name
}

if _, ok := m[pkgName]; ok {
Expand Down
46 changes: 46 additions & 0 deletions mockgen/tests/vendor_dep/source_mock_package/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 42764bf

Please sign in to comment.