Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
fix command to install mockgen
Browse files Browse the repository at this point in the history
  • Loading branch information
balshetzer authored Apr 27, 2018
1 parent 8b2eeeb commit 87f106f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Once you have [installed Go][golang-install], run these commands
to install the `gomock` package and the `mockgen` tool:

go get github.com/golang/mock/gomock
go get github.com/golang/mock/mockgen
go install github.com/golang/mock/mockgen


Documentation
Expand Down

5 comments on commit 87f106f

@MOZGIII
Copy link

@MOZGIII MOZGIII commented on 87f106f Jun 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of using go install instead of go get?

@balshetzer
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go get just grabs the code.

go install grabs the code, builds the mockgen binary and puts it into the bin directory, which is usually in your PATH so you can run it.

That said, feel free to do whatever works for you.

@MOZGIII
Copy link

@MOZGIII MOZGIII commented on 87f106f Jun 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go get seems to put gomock in my $GOPATH/bin. I never actually understood the difference between the two. Does go get really not build and put gomock to the $GOPATH/bin for you? For me it does...

➜  ~ rm `which mockgen`                   
➜  ~ mockgen           
zsh: command not found: mockgen
➜  ~ go get github.com/golang/mock/mockgen
➜  ~ mockgen                              
mockgen has two modes of operation: source and reflect.
...
2018/06/07 20:14:48 Expected exactly two arguments

I just found this commit and was wondering if you know what's with go get/go install, and what's the actual difference in behavior.
Docs describe same differences between the two, but I don't get it.

@LasTshaMAN
Copy link

@LasTshaMAN LasTshaMAN commented on 87f106f Jul 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MOZGIII Hi

Stumbled upon this thread, also was looking for the difference between go get / go install.
I think, go install is a subset of go get (after downloading the package go get calls go install or something like that). Go install compiles mockgen tool and puts it under $GOPATH/bin.

The thing is, when we call go get github.com/golang/mock/gomock we download not only gomock folder (and corresponding gomock package), but also the rest of the mock repository as well (that is mockgen folder) - I didn't figure out why that is just yet, but looks like it is how it works.
Thus, it is enough for us to call go install github.com/golang/mock/mockgen to create mockgen instead of go get github.com/golang/mock/mockgen as mockgen source code is already there.

So, @balshetzer, my question would be - how is that go get github.com/golang/mock/gomock downloads mockgen source code also ?

@MOZGIII
Copy link

@MOZGIII MOZGIII commented on 87f106f Jul 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be the case. I'll feel like I just need to read the source code - the answer must be there.

go get just clones whatever the repo is (git repo github.com/golang/mock in this case). Everything gets loaded. Even for go get github.com/golang/mock/whatever the git repo github.com/golang/mock is detected and used.

Please sign in to comment.