Installing go modules from Github repository
1 min readJul 15, 2020
First Thing First
For building Go projects we need to install the Go binary. The official installation document is a great place to look at. Also, you will need to set the GOPATH environment variable.
The Magic Command
go get -u github.com/IBM-Cloud/terraform-provider-ibm
Option -u
instructs ‘get’ to update the module with dependencies.
Note that the module path is without the HTTP(s) protocol.
UPDATE 14th Jan 2022:
From Go version 1.18go get
command will no longer install the packages. Make use of go install
instead.
Building and installing packages with get is deprecated. In a future release, the -d flag will be enabled by default, and 'go get' will be only be used to adjust dependencies of the current module. To install a package using dependencies from the current module, use 'go install'. To install a package ignoring the current module, use 'go install' with an @version suffix like "@latest" after each argument.
How does it work?
This will pull the source at $GOPATH/src/github.com/IBM-Cloud/terraform-provider-ibm/
on the machine.
The final binary can be found at $GOPATH/bin/terraform-provider-ibm
Again, to find where is the $GOPATH
?
go env GOPATH
References: