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

Always remove self_package import #343

Merged
merged 4 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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