Hey while running the mockgen command to create mock file, i am getting below error, do you have any idea why is there this error, it says go mod file not found, but it is present there.
missing go.sum entry for module providing package github.com/golang/mock/mockgen/model; to add:
go mod download github.com/golang/mock
prog.go:12:2: missing go.sum entry for module providing package github.com/golang/mock/mockgen/model; to add:
go mod download github.com/golang/mock
prog.go:14:2: no required module provides package github.com/acetorscode/learningbank/db/sqlc: go.mod file not found in current directory or any parent directory; see 'go help modules'
prog.go:12:2: no required module provides package github.com/golang/mock/mockgen/model: go.mod file not found in current directory or any parent directory; see 'go help modules'
2021/05/31 19:12:53 Loading input failed: exit status 1
As the readme on their github repo, there are some workaround solutions:
Include an empty import import _ "github.com/golang/mock/mockgen/model".
Add --build_flags=--mod=mod to your mockgen command.
I had the same error as you and I did the second one successfully. mockgen -build_flags=--mod=mod -package mockdb -destination db/mock/store.go github.com/phihdn/simplebank/db/sqlc Store
thank you so so much, I registered just here to say thank you. How are you able to find this solution? I searched for long didn't find a usable solution lol
Hey while running the mockgen command to create mock file, i am getting below error, do you have any idea why is there this error, it says go mod file not found, but it is present there.
missing go.sum entry for module providing package github.com/golang/mock/mockgen/model; to add:
go mod download github.com/golang/mock
prog.go:12:2: missing go.sum entry for module providing package github.com/golang/mock/mockgen/model; to add:
go mod download github.com/golang/mock
prog.go:14:2: no required module provides package github.com/acetorscode/learningbank/db/sqlc: go.mod file not found in current directory or any parent directory; see 'go help modules'
prog.go:12:2: no required module provides package github.com/golang/mock/mockgen/model: go.mod file not found in current directory or any parent directory; see 'go help modules'
2021/05/31 19:12:53 Loading input failed: exit status 1
As the readme on their github repo, there are some workaround solutions:
import _ "github.com/golang/mock/mockgen/model"
.--build_flags=--mod=mod
to your mockgen command.I had the same error as you and I did the second one successfully.
mockgen -build_flags=--mod=mod -package mockdb -destination db/mock/store.go github.com/phihdn/simplebank/db/sqlc Store
thank you so so much, I registered just here to say thank you. How are you able to find this solution? I searched for long didn't find a usable solution lol
Hi, I don't remember. It might be Google or I might walk around their github Issues page. Then I found it in the readme. :) happy to hear it helps.