Hello world in golang

Go programs are organized into packages - a collection of source files in the same directory that compile together.

Since the need it to be executable - we need this package main in the file main.go:

package main

import (
  "fmt"
)

func main() {
  fmt.Println("Hello world!")
}
In this file we have a function which starts with func main() - it takes no parameters and has no return.

To print some words - we need to import some packages like fmt.

Let's run this and see what's happens:
go run main.go
You can also build the binary:
go build main.go
and run that binary:
./main
Ofcourse - everytime we change the code, we have to rebuild the file.