Go lang course

Go Programming Setup (for Mac)

Before we start programming in Go there are a few things we need to prepare. Doing this once on the computer you will use will be sufficient.

  • Install Go
  • Install a Code Editor
  • Install Command Line Tools
  • Install Go Libraries

To begin, Go needs to be installed on the computer you will be using.  Go should already be installed from the previous step, however if it is not please return to the previous page and complete the installation.

A code editor will be used for programming in Go. The program will be saved as a text file, so a text editor can be used, but using a special code editor will color code the structure and syntax of the language making it easier to read and simplifying programming.

There are many different code editors but let’s use Atom. To get Atom go to the link below and press the Download button.

https://atom.io/

After the download is finished, double click on the downloaded file to launch the installer. Follow the installer’s guide to complete the installation.

Point On the Mac, move Atom.app to the Applications Folder so that you can launch Atom using the command atom . in the Terminal.

We will use the terminal to execute our Go program, and install libraries. The Mac has a terminal installed from the start, but let’s install this easy to use one.

On the Mac install iTerm2. Go to the site below, press the Download button, and double click on the downloaded file to start the installation.

https://iterm2.com/

Lastly we will install some useful libraries for making games in Go. Start the Terminal (iTerm2) and copy and paste and execute the commands below.

go get github.com/faiface/pixel
go get github.com/faiface/glhf
go get -u github.com/go-gl/gl/v3.3-core/gl
go get -u github.com/go-gl/glfw/v3.2/glfw

And with that our setup for Go Programming is complete. To make sure our environment is properly set up, let’s try executing this sample game.

go get github.com/faiface/pixel-examples
cd ~/go/src/github.com/faiface/pixel-examples/platformer/
go run main.go

If the game window opens and you can control the character the installation was a success!