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

Commit

Permalink
Always remove self_package import (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhp authored and codyoss committed Jan 14, 2020
1 parent 0800f9a commit e00cb15
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
47 changes: 47 additions & 0 deletions mockgen/internal/tests/self_package/mock.go

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

10 changes: 10 additions & 0 deletions mockgen/internal/tests/self_package/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:generate mockgen -package core -self_package github.com/golang/mock/mockgen/internal/tests/self_package -destination mock.go github.com/golang/mock/mockgen/internal/tests/self_package Methods
package core

type Info struct {
name string
}

type Methods interface {
getInfo() Info
}
3 changes: 2 additions & 1 deletion mockgen/mockgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ func sanitize(s string) string {
}

func (g *generator) Generate(pkg *model.Package, outputPkgName string, outputPackagePath string) error {
if outputPkgName != pkg.Name {
if outputPkgName != pkg.Name && *selfPackage == "" {
// reset outputPackagePath if it's not passed in through -self_package
outputPackagePath = ""
}

Expand Down

0 comments on commit e00cb15

Please sign in to comment.