This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
87f106f
There was a problem hiding this comment.
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 ofgo get
?87f106f
There was a problem hiding this comment.
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.
87f106f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go get
seems to putgomock
in my$GOPATH/bin
. I never actually understood the difference between the two. Doesgo get
really not build and putgomock
to the$GOPATH/bin
for you? For me it does...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.
87f106f
There was a problem hiding this comment.
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 ofgo get
(after downloading the packagego get
callsgo install
or something like that). Go install compilesmockgen
tool and puts it under$GOPATH/bin
.The thing is, when we call
go get github.com/golang/mock/gomock
we download not onlygomock
folder (and correspondinggomock
package), but also the rest of themock
repository as well (that ismockgen
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 createmockgen
instead ofgo get github.com/golang/mock/mockgen
asmockgen
source code is already there.So, @balshetzer, my question would be - how is that
go get github.com/golang/mock/gomock
downloadsmockgen
source code also ?87f106f
There was a problem hiding this comment.
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 repogit.luolix.top/golang/mock
in this case). Everything gets loaded. Even forgo get github.com/golang/mock/whatever
the git repogit.luolix.top/golang/mock
is detected and used.