-
Notifications
You must be signed in to change notification settings - Fork 607
importing "golang.org/x/net/context" in controller.go #124
Comments
Duplicate to #116 |
This is actually the inverse of #116. The problem in #116 was that we imported context from the standard library so users of an old version of gomock had compilation problems. To solve that we imported golang.org/x/net/context instead. This bug is saying that the compilation failed because golang.org/x/net/context was not found. This issue is easily fixed by running "go get". @zut please try "go get" and report back. |
Hi! I'm rather new to go, so not quite sure what's important to know to track this down. I installed mockgen via I modified it to compile and worked on for a while. Then I did I don't know if I can find the version in the sources somehow to know what
|
Older versions of Go (pre 1.7) didn't have a "context" package. If we import "context" then gomock breaks for them. There exists an external package, "golang.org/x/net/context", which is the same package. Using that works for both new and old versions of Go. The problem that you ran into was that gomock has a dependency on that package but you hadn't downloaded that package. I believe that the go tool is supposed to get dependencies for you automatically but I'm not sure of the details. That's why I suggested running |
Do you mean I should first do Right now if I run |
You would run |
I think the root of this issue is that gomock has an external dependency but I think it should be fine for gomock to have an external dependency. I'm open to suggestions though on how to make this easier, especially if there are common practices for managing external deps in Go projects. |
Closing for now. Feel free to re-open. |
@praveen691cs I'm not seeing that github.com/golang/mock is referenced in that screen shot. Am I missing it? |
sorry i didn't get you. could you please explain it a bit more. |
@praveen691cs I am asking if you are suggesting |
In
github.com/golang/mock/gomock/controller.go
I get an issue:This seems to be resolved by instead just importing
context
, as per https://stackoverflow.com/questions/42802278/install-context-package-in-golang. With an updated controller.go with lines 58-64 as below, it works fine for me.(running go version go1.9 darwin/amd64)
The text was updated successfully, but these errors were encountered: