What version of trpc-cmdline are you using?
v1.0.9
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/tyanxie/Library/Caches/go-build'
GOENV='/Users/tyanxie/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/tyanxie/Projects/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/tyanxie/Projects/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/Users/tyanxie/DevTools/gos/go1.22.2'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/tyanxie/DevTools/gos/go1.22.2/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/z8/0hqvm5bx7058y4tghsqv9q2h0000gn/T/go-build492708761=/tmp/go-build -gno-record-gcc-switches -fno-common'
What did you do?
download the docs/helloworld/helloworld.proto file and run trpc create -p helloworld.proto -o .
What did you expect to see?
- the test cases in the generated
hello_world_service_test.go file can be executed directly without modification, even if it makes no sense
- the generated stub code
helloworld_mock.go reported no error
What did you see instead?
- two errors in the
hello_world_service_test.go file
- before executing
go mod tidy, the helloworld_mock.go file reported an error
My thoughts 1
I used the trpc setup command to install the mockgen command.
It looks like the installed mockgen is github.com/golang/mock/mockgen, so the stub code helloworld_mock.go generated using the trpc create command introduced github.com/golang/mock library.
However, the hello_world_service_test.go and go.mod files tend to import the go.uber.org/mock library, thus causing some of the errors. (In addition, I noticed that the manual installation of dependencies in the README.md document also tends to install go.uber.org/mock)
Regarding this issue, I think two points should be carefully considered:
- It is necessary to check and unify the dependence on the
mock library.
- Do you need to try to be compatible with both
mockgen libraries? Although go.uber.org/mock is now more recommended, some users also install github.com/golang/mock/mockgen locally.
My thoughts 2
For the gomock.InOrder function used in line 28 of the file hello_world_service_test.go, the parameter it accepts is ...any, but it seems that the parameter currently passed in is ...*gomock.Call, That's why there is such an error.
In short, I expect that the test code can be run directly after executing the trpc create command without modifying anything.
What version of trpc-cmdline are you using?
v1.0.9
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
download the
docs/helloworld/helloworld.protofile and runtrpc create -p helloworld.proto -o .What did you expect to see?
hello_world_service_test.gofile can be executed directly without modification, even if it makes no sensehelloworld_mock.goreported no errorWhat did you see instead?
hello_world_service_test.gofilego mod tidy, thehelloworld_mock.gofile reported an errorMy thoughts 1
I used the
trpc setupcommand to install themockgencommand.It looks like the installed
mockgenisgithub.com/golang/mock/mockgen, so the stub codehelloworld_mock.gogenerated using thetrpc createcommand introducedgithub.com/golang/mocklibrary.However, the
hello_world_service_test.goandgo.modfiles tend to import thego.uber.org/mocklibrary, thus causing some of the errors. (In addition, I noticed that the manual installation of dependencies in theREADME.mddocument also tends to installgo.uber.org/mock)Regarding this issue, I think two points should be carefully considered:
mocklibrary.mockgenlibraries? Althoughgo.uber.org/mockis now more recommended, some users also installgithub.com/golang/mock/mockgenlocally.My thoughts 2
For the
gomock.InOrderfunction used in line 28 of the filehello_world_service_test.go, the parameter it accepts is...any, but it seems that the parameter currently passed in is...*gomock.Call, That's why there is such an error.In short, I expect that the test code can be run directly after executing the
trpc createcommand without modifying anything.