HiveBrain v1.2.0
Get Started
← Back to all entries
gotchagoCritical

What is the difference between go get and go install?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
installandbetweenthedifferencewhatget

Problem

After playing with the go tool for a while, it looks like go get:

  • (optionally) downloads,



  • compiles,



  • and installs



a piece of software, while go install simply

  • compiles



  • and installs



it. In this case, why does the go install command exist, since go get supersedes it?

Solution

go install is part of the workflow when working locally. Say you want to use a library, but for some reason a change is required. You would do:

  • go get -d library, which only downloads it;



  • make the change on the downloaded package;



  • go install library to install the local version.



As far as I know go get has no flags to indicate it should not download, so it can't replace go install here.

The same workflow is used when you develop a new package from scratch.

EDIT: six years later, Go 1.16 has updated and clarified the usage of go install and go get: https://tip.golang.org/doc/go1.16#modules

go install, with or without a version suffix (as described above), is now the recommended way to build and install packages in module mode. go get should be used with the -d flag to adjust the current module's dependencies without building packages, and use of go get to build and install packages is deprecated. In a future release, the -d flag will always be enabled.

Context

Stack Overflow Q#24878737, score: 148

Revisions (0)

No revisions yet.