golang/mock

Not able to generate mocks for vendor interfaces

gogetkarthik opened this issue · 1 comments

Actual behavior A clear and concise description of what the bug is.
trying to generate the mocks but failing with following error, my interface is in the vendor folder
//go:generate mockgen -destination mock_st_core.go github.com/xxxx/Client/hello ClientService

prog.go:12:2: cannot find package "." in:
Users/pp/go/src/xxxxxxx/vendor/github.com/golang/mock/mockgen/model
prog.go:12:2: cannot find package "." in:
/Users/pp/go/src/xxxxxxx/vendor/github.com/golang/mock/mockgen/model
prog.go:14:2: cannot find module providing package /Users/pp/go/src/xxxxxxx/Client/hello: working directory is not part of a module
prog.go:12:2: cannot find module providing package github.com/golang/mock/mockgen/model: working directory is not part of a module
2020/04/04 13:19:55 Loading input failed: exit status 1
generate.go:1: running "mockgen": exit status 1

go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/pp/Library/Caches/go-build"
GOENV="/Users/pp/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/pp/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/local/Cellar/go/1.14.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zr/h_st3mps3t9_76gz8tng6qmm0000gn/T/go-build053824840=/tmp/go-build -gno-record-gcc-switches -fno-common"`
Expected behavior A clear and concise description of what you expected to
happen.
mocks should be gener

To Reproduce Steps to reproduce the behavior
generate mocks for interfaces preset in vendor folder.

Additional Information

  • gomock mode (reflect or source): github.com/golang/mock v1.4.3 // indirect
  • gomock version or git ref: github.com/golang/mock v1.4.3 // indirect
  • golang version: go version go1.14.1 darwin/amd64

Triage Notes for the Maintainers

I got this resolved by following
$ go get github.com/golang/mock/gomock
$ go install github.com/golang/mock/mockgen
$go get golang.org/x/tools/go/packages
Ref: #266