Go is a programming language that was developed by Google. The language is often referred to as Golang. It was designed to have three features available at the same time - fast compilation, ease of programming, and efficient execution in production.
This guide will help you through installing Go on your local machine and setting up a programming workspace via the command line.
Let's get started. 🚀
Installing and Setting Up Homebrew
Homebrew provides macOS with a free and open-source software package managing system that simplifies the installation of software on macOS.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing GO
You can use Homebrew to search for all available packages with the brew search
command.
$ brew search golang
The terminal will output a list of what you can install.
golang golang-migrate
Now, install golang with brew install
command.
$ brew install golang
To check the version of Go that you installed use the following command.
$ go version
Creating Your Go Workspace
-
src
: The directory that contains Go source files. A source file is a file that you write using the Go programming language. Source files are used by the Go compiler to create an executable binary file. -
bin
: The directory that contains executables built and installed by the Go tools. Executables are binary files that run on your system and execute tasks. These are typically the programs compiled by your source code or another downloaded Go source code.
The default directory for the Go workspace home directory with a go subdirectory, or $HOME/go.
Issue the following command to create the directory structure for your Go workspace:
$ mkdir -p $HOME/go/{bin,src}
First, open ~/.bash_profile
with your preferred text editor and set up the $GOPATH
.
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
Congratulations! You have a Go programming workspace set up on your local machine and can begin to write your first Go program. 🚀
Thanks for reading. Happy Learning! ❤️
Top comments (0)