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

Not able to generate mocks for vendor interfaces #423

Closed
gogetkarthik opened this issue Apr 4, 2020 · 1 comment
Closed

Not able to generate mocks for vendor interfaces #423

gogetkarthik opened this issue Apr 4, 2020 · 1 comment

Comments

@gogetkarthik
Copy link

gogetkarthik commented Apr 4, 2020

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

@gogetkarthik
Copy link
Author

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

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

1 participant