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

Commit 485faf3

Browse files
authored
Merge pull request #167 from golang/iss166
Fix #166
2 parents 69521b3 + 42764bf commit 485faf3

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

mockgen/parse.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,13 @@ func importsOfFile(file *ast.File) map[string]string {
444444
pkg, err := build.Import(importPath, "", 0)
445445
if err != nil {
446446
// Fallback to import path suffix. Note that this is uncertain.
447-
log.Printf("failed to import package by path %s: %s - fallback to import path suffix", importPath, err.Error())
448447
_, last := path.Split(importPath)
449448
// If the last path component has dots, the first dot-delimited
450449
// field is used as the name.
451450
pkgName = strings.SplitN(last, ".", 2)[0]
451+
} else {
452+
pkgName = pkg.Name
452453
}
453-
pkgName = pkg.Name
454454
}
455455

456456
if _, ok := m[pkgName]; ok {

mockgen/tests/vendor_dep/doc.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
package vendor_dep
22

33
//go:generate mockgen -package vendor_dep -destination mock.go github.com/golang/mock/mockgen/tests/vendor_dep VendorsDep
4+
//go:generate mockgen -destination source_mock_package/mock.go -source=vendor_dep.go

mockgen/tests/vendor_dep/source_mock_package/mock.go

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)