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

Mockgen installed with go modules cannot find own source #266

Closed
Helvind opened this issue Feb 14, 2019 · 9 comments
Closed

Mockgen installed with go modules cannot find own source #266

Helvind opened this issue Feb 14, 2019 · 9 comments

Comments

@Helvind
Copy link

Helvind commented Feb 14, 2019

I use go modules, and have followed the installation guidelines:

go get github.com/golang/mock/gomock
go install github.com/golang/mock/mockgen

But when I run mockgen it failes to find mockgen/models because it does not expect the source to be in the pkg/mod folder, but in src

@Helvind Helvind closed this as completed Feb 21, 2019
@shreyashk2006
Copy link

@bhcleek: What was the resolution to this?

@rodoufu
Copy link

rodoufu commented Jul 11, 2019

I've runned this:

$ go get github.com/golang/mock/gomock
$ go install github.com/golang/mock/mockgen

But when I try to find mockgen nothing is shown.

$ which mockgen
$

@poy
Copy link
Collaborator

poy commented Jul 11, 2019

Is $GOPATH/bin in your PATH?

@rodoufu
Copy link

rodoufu commented Jul 11, 2019

Is $GOPATH/bin in your PATH?

Yes, the soluiton was:

go get golang.org/x/tools/go/packages

Now it's working, thanks.

@CssHammer
Copy link

@Helvind have you found the solution?

@tommyjcarpenter
Copy link

tommyjcarpenter commented Jul 22, 2020

I am still having this issue and the solution of packages did not fix it.

In my case I am trying to bump quay.io/goswagger/swagger:v0.23.0 to quay.io/goswagger/swagger:v0.24.0 which leads to

# xxx/models
../../models/cluster.go:230:12: undefined: validate.EnumCase
../../models/job.go:142:12: undefined: validate.EnumCase
../../models/job.go:185:12: undefined: validate.EnumCase
# xxx/models
../../models/cluster.go:230:12: undefined: validate.EnumCase
../../models/job.go:142:12: undefined: validate.EnumCase
../../models/job.go:185:12: undefined: validate.EnumCase
prog.go:12:2: cannot find package "github.com/golang/mock/mockgen/model" in any of:
        /usr/local/Cellar/go/1.14.5/libexec/src/github.com/golang/mock/mockgen/model (from $GOROOT)
        /Users/tommy/Development/go/src/github.com/golang/mock/mockgen/model (from $GOPATH)
2020/07/22 08:58:17 Loading input failed: exit status 1
worker/cluster_manager.go:17: running "mockgen": exit status 1
make: *** [generate] Error 1

@fefi42
Copy link

fefi42 commented Jul 24, 2020

I have had the same issue

updating all go-openapi to the newest versions in go.mod solved it.

@DevilzOwn
Copy link

@tommyjcarpenter Were you able to find a solution for this? What was your workaround for this?
Why does it look into local directories for "github.com/golang/mock/mockgen/model" ?

@tommyjcarpenter
Copy link

tommyjcarpenter commented May 17, 2022

@DevilzOwn unfortunately, I am no longer at the company with that codebase - it's been a couple of years about and I forget those details :(. Sorry!

However, there's a non-0 chance I will be working with this package again soon, so maybe I'll be back here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants