I add a test file for a package using gomock to an existing Go project, and now I am getting
...imports github.com/golang/mock: build constraints exclude all Go files in /home/bserdar/go/pkg/mod/github.com/golang/[email protected]
when I run go test
from one of the packages using gomock. There are no build constraints in my project. Any idea what is wrong here?
It's not saying any files in your project are excluded, it specifically says all files in github.com/golang/mock are excluded, which is accurate; that's not an importable package, it doesn't contain anything. You should be importing the subpackages you need - or rather, per the documentation, you should be generating mocks using the tool, and the generated files should be importing valid packages.