Welcome to the Golang Tutorial! This is your very first program. There are exercises below the tutorials.

Quick Start

Create a hello world app

One of the easiest programs:
a program that displays “Hello world”.

Start by creating a new file (hello.go) with this contents:

1
2
3
4
5
6
7
package main

import "fmt"

func main() {
fmt.Println("Hello, World!")
}

We import the essentials. Then create the main function which is where the program starts. Finally we output the text “Hello world” with the line:

1
fmt.Println("Hello, World!")

Run app

To run a go program, open the command line. Move into the directory that has your program, like:

1
cd /home/tux/GoProjects/

You should now be in the directory that has your program (hello.go).

Run the program with the command below.

1
$ go run hello.go

This will then output the message “Hello, World!” to the screen

Video

Video tutorial below:

Exercise

  1. Create a program that shows your name
  2. Create a program that shows your address