We are working with Go modules. I want in a CLI to get the specific version of a module. Is it possible?
If you are curious, the reason is that I want to add the following generate
command:
//go:generate go run github.com/golang/mock/mockgen -source="$GOPATH/pkg/mod/mymodules.com/mymodule@${VERSION}/module.go" -destination=module_mock.go
So I need to somehow get the version
go.mod
file?go.mod
right?go list -m -u all
piped togrep
would do it, but I'd try to avoid generating mocks of a third-party package. Rather, write an interface for it in your own project, and mock that.go mod vendor
, then all module packages will be available in the local directory without versions. That will make-source="vendor/mymodules.com/mymodule/module.go"
work.