golang / mock

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

Unresolved Reference T #613

Closed SamuelCabralCruz closed 2 years ago

SamuelCabralCruz commented 2 years ago

Just tried out using gomock and faced the issue that generated mock make reference to m.ctrl.T but there is no getter on test reporter t field.

SamuelCabralCruz commented 2 years ago

After browsing the code in the master branch, I observed that T is now a public Field.

The problem was that I was using gomock v1.1.1. I went in my project root folder and did the following: go mod tidy I observed that a require was added to my go.mod file github.com/golang/mock v1.1.1 I then updated the version manually to 1.6.0 and ran another go mod tidy and afterward the autogenerated code was compiling properly.

I don't know if there is a way to specify a minimal version for go mod to be downloaded along with mockgen, but those two dependencies should probably be in sync. At least, better documentation in the project readme could be useful for neofit users like me.

codyoss commented 2 years ago

In general mockgen and the library should be in sync. The only way to really pin a version /w go.mods is to use replace directives. What sort of documentation in the README would have helped you here?

SamuelCabralCruz commented 2 years ago

maybe just a line explicitly saying that github.com/golang/mock vX.X.X must be added to go.mod I guess or to execute go mod tidy after installing mockgen and to make sure both versions are in sync I guess.