golang / mock

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

mockgen issues on golang 1.9.7 #273

Closed thomas91310 closed 5 years ago

thomas91310 commented 5 years ago

Yesterday, because I didn't pin the golang/mock version, I started getting this error on CI:

circleci@6d164783e148:/go/src/github.com/thomas91310/blah/app/monitor$ mockgen -package=monitor -destination=./route_tracer_mock.go -source=route_tracer.go
/tmp/gopackages445548346/runtime_cgo/cgo.cgo1.go:1: no such file or directory
/tmp/gopackages445548346/net/cgo_linux.cgo1.go:1: no such file or directory
/tmp/gopackages445548346/net/cgo_resnew.cgo1.go:1: no such file or directory
/tmp/gopackages445548346/net/cgo_socknew.cgo1.go:1: no such file or directory
/tmp/gopackages445548346/net/cgo_unix.cgo1.go:1: no such file or directory
2019/03/12 19:38:24 Loading input failed: loading package failed

This is the go version and I have a feeling the issue might be related to this (meaning upgrading to go 11 would not generate this problem):

circleci@6d164783e148:/go/src/github.com/thomas91310/blah/app/monitor$ go version
go version go1.9.7 linux/amd64

This is the go env:

circleci@6d164783e148:/go/src/github.com/thomas91310/blah/app/monitor$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build375075997=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

This fixes the problem:

circleci@6d164783e148:/go/src/github.com/golang/mock$ git reset --hard bfa1e97ed7a159b123865559eabdec69b78fe1d5
circleci@6d164783e148:/go/src/github.com/golang/mock$ cd mockgen/
circleci@6d164783e148:/go/src/github.com/golang/mock/mockgen$ go install

Back to my repo where I setup mocks:

circleci@6d164783e148:/go/src/github.com/thomas91310/blah/app/monitor$ cd /go/src/github.com/thomas91310/blah/app/monitor
circleci@6d164783e148:/go/src/github.com/thomas91310/blah/app/monitor$ mockgen -package=monitor -destination=./route_tracer_mock.go -source=route_tracer.go
circleci@6d164783e148:/go/src/github.com/thomas91310/blah/app/monitor$ ls -lahtr route_tracer_mock.go
-rw-r--r-- 1 circleci circleci 1.5K Mar 12 19:44 route_tracer_mock.go

Didn't really investigate further but it seems to be coming from you since the mockgen package was updated 22 hours ago right when we started seeing our builds fail?

balshetzer commented 5 years ago

The head version of gomock no longer supports go1.9. In general, we support the last three major releases. Once go12 was released we added support for modules, which broke compatibility with go1.9. This was intentional in the sense that we held off on this change until 1.9 was no longer one of the last three major releases.

thomas91310 commented 5 years ago

cool, thanks for the explanation! We can close this then