Go is a computer programming language. It is sometimes called “Google Go” or “golang”. Go programs run on popular operating systems (Windows, OSX, Linux).

Introduction to Go

Go files

Go programs are stored in files. Computer systems contain millions of files. These files can be video files, images, sound and other types of data.

In the case of Go programs, they are stored in code files. A program consists of lines of text.

Each file can have an extension. An extension is the word that comes after the dot. If you have a file “beach.bmp”, the first part before the dot is the filename. The last part after the dot is the exension (bmp).

For Go programs, the extension is (.go).

Folders (or directories) are used to group files together. For each software project, you’ll want to have your files in a project folder.

Terminal

The terminal, sometimes called command line interface, is very often used by programmers. Typically this is a black and white screen which only displays text, on OSX its often white on black.

The programmer types commands, to which the computer reacts.

You can start Go programs from the terminal.

To open a terminal:

  • Windows: hold the windows key and press r. Then type cmd.exe and hit the return key.
  • OSX: Go to Finder -> Applications -> Utilities -> Terminal.

You can then navigate to your project folder with the cd command. On OSX that may be:

{% codeblock %} cd /Users/dog/Projects/hello


On Windows the folder system is different, it may be

{% codeblock %}
cd C:\Users\dog\Projects\go

You can also navigate a single directory down (cd folder) or up (cd ..). This works on both systems. To see the files in a map, type “ls” or “dir”.

Run Go program

You can run Go programs from the terminal. If you have a program named “icecream.go”, you can start it with the command:

{% codeblock %} go run icecream.go ```

The output will be shown on the screen.

To run this command, Go must be installed.