DEV Community

Discussion on: Mock DB for testing HTTP API in Go and achieve 100% coverage

Collapse
 
phihdn profile image
Phi Hoang

As the readme on their github repo, there are some workaround solutions:

  1. Include an empty import import _ "github.com/golang/mock/mockgen/model".
  2. 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

Collapse
 
devtianze profile image
Tianze Hua

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

Thread Thread
 
phihdn profile image
Phi Hoang

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.