golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.29k stars 610 forks source link

Can't run mockgen (due to Go modules?) #212

Closed aknuds1 closed 5 years ago

aknuds1 commented 5 years ago

I've just installed mock according to the instructions in the README, using Go 1.11 on OS X, but I'm unable to run it. See below for the error that occurs, I wonder if it might have to do with the experimental modules support in Go 1.11 (which I've opted into)?

go version go1.11 darwin/amd64
➜  experimental-berlin-image-processing git:(master) go get github.com/golang/mock/gomock
go: finding github.com/golang/mock/gomock latest
➜  experimental-berlin-image-processing git:(master) go install github.com/golang/mock/mockgen
➜  experimental-berlin-image-processing git:(master) mockgen net/http Get
prog.go:11:2: cannot find package "github.com/golang/mock/mockgen/model" in any of:
    /usr/local/Cellar/go/1.11/libexec/src/vendor/github.com/golang/mock/mockgen/model (vendor tree)
    /usr/local/Cellar/go/1.11/libexec/src/github.com/golang/mock/mockgen/model (from $GOROOT)
    /Users/arve/go/src/github.com/golang/mock/mockgen/model (from $GOPATH)
# command-line-arguments
./prog.go:22:27: invalid indirect of http.Get (type func(string) (*http.Response, error))
prog.go:11:2: cannot find package "github.com/golang/mock/mockgen/model" in any of:
    /usr/local/Cellar/go/1.11/libexec/src/github.com/golang/mock/mockgen/model (from $GOROOT)
    /Users/arve/go/src/github.com/golang/mock/mockgen/model (from $GOPATH)
2018/09/24 00:18:59 Loading input failed: exit status 1

You can see my repo here if it's relevant for debugging.

kishaningithub commented 5 years ago

Hi @aknuds1 Running mockgen like

GO111MODULE=on mockgen

fixed the problem for me

poy commented 5 years ago

This looks more like a setup issue over a gomock issue. Are you seeing this issue with any other repo?

bithavoc commented 5 years ago

Should we discuss this here or in https://github.com/golang/mock/issues/283 ?

bithavoc commented 5 years ago

This issue was fixed, see the solution for my particular case here

poy commented 5 years ago

I'm closing this due to lack of activity. Please feel free to reopen.