Jeff Flowers / 08 June 2015 / Tutorials / 14336

Go is a powerful new programming language, allowing for rapid prototyping of all types of web apps.  The following is a beginner’s guide to installing this language on a Mac running OS X 10.10.3.  You will need to have Go installed should you wish to also install other tools, such as IPFS later down the road.  This tutorial assumes no prior knowledge.  Enjoy and get developing.

Overview:

  1. Procuring and Checking the Go Language Package
  2. Installing the Go Programming Language
  3. Verifying the Installation Process
  4. Writing a Go Program Using TextEdit

1. Procuring and Checking the Go Language Package

  1. Go to the following website:  https://www.golang.org/
    Go website
  2. Select the “Download Go” button.  You will be taken to the webpage containing the different versions of Go for various setups.
    Download Go
  3. Click on “Download Go” to get to the actual distributions of the package.
    Download Go
  4. Find the correct copy for your system.  Since this tutorial is for Mac OS X 10.10.3, we would select:  go1.4.2.darwin-amd64-osx10.8.pkg
    Go versions

2. Installing the Go Programming Language

After clicking on the selected package, it will be automatically downloaded to your computer.  You might have noticed in the download table a column labeled:  SHA1 Checksum.  We will use that to verify that our copy matches.

  1. Open a new terminal.
    open terminal
  2. We will now locally hash the file to ensure that the checksums shown are those of the file that we have just downloaded.  In a terminal window type the following:
    >openssl sha1 <FileYouJustDownloaded> <enter>
    Hash Go download
  3. Check that the result matches with that found for your file in the download table on the website.  These must be identical; otherwise, the file have been corrupted and should not be used.  Below is the locally hashed file atop of the SHA1 listed on the website.  Notice that the two strings are identical.
    Verifying download hashes
  4. Now that the file has been verified as being correct, open the package to begin the install process:
    install Go
  5. The installation process will take you through the various steps needed for the software.
    Go installation
  6. You will need to enter your admin password for the install process to work.
    Go installation - password
  7. Make certain that the software has successfully installed.
    Installation successful

3. Verifying the Installation Process

  1. Open the Terminal application, in order to double check that the installation was successful.
    Open terminal
  2. To check that Go has been installed and configured for you system, type the following command:

    >go version <enter>

  3. If your system has had the software installed correctly, you should see the correct version number of the software.
    Go version

4. Writing a Go Program Using TextEdit

Now that we have Go installed, we can write a test program in TextEdit.  TextEdit is a text editor that comes with Mac OS.  Before using it though, we will see that some changes to the default settings will be necessary for us to use it properly.

  1. Open TextEdit:
    Open TextEdit
  2. Create a default file and type the following inside of it:
    TextEdit create file

  3. When you attempt to save the file with the “go” extension, TextEdit will add “rtf”:
    TextEdit rtf
  4. In order for a go program to properly run, it must only have a “go” extension.  This will require that we make changes to the program’s preferences.  Opening Preferences you will see the following:
    TextEdit settings
  5. Make the following changes:
    TextEdit settings
  6. Similarly, under the “Open and Save” the defaults are:
    TextEdit settings
  7. Make the following changes:
    TextEdit settings
  8. With these settings, it will now be possible to save your file in a format that go will be able to understand.

Add comment


Security code Refresh

Talk to Us!

Get a quote, give us suggestions, or send us a hello :)

816.983.6923

San Mateo, California

PGP: 20AE A7E7 6CA8 F81B 4FB1 C942 BA34 7830 1DEB 320E