Install GoLang And Setup GOPATH
Installation
- Download the Go installer from the Go downloads page.
- Open the installer package. This will launch the Go installer.
- Follow the prompts in the installer to install Go. The installer will ask you for a installation location; by default, Go will be installed in
/usr/local/go
. - Once the installation is complete, open a terminal window and type the following command to verify that Go was installed correctly:
go version
This should print the version of Go that you installed.
Setup GOPATH
You may also need to set the GOPATH
environment variable. This variable specifies the location of your Go workspace, which is where Go will look for your Go source code and packages. To set the GOPATH
variable, open your ~/.bash_profile
file and add the following line:
export GOPATH=$HOME/go
Replace $HOME/go
with the desired location of your Go workspace.
Then, run the following command to apply the changes:
source ~/.bash_profile
You are now ready to use Go on your machine :)
I have more articles about the programming world and I also write articles and stories about Life, IT Lessons and Technology, If you’d care to read more, follow me on Medium :)