Why Hello, World! Link to heading

If you already know how to program and getting started on Go, the first program to write is “Hello, World!”. The basic reason for this is to ensure that the environment is all working well and you can compile and run the program without any issues.

First step is to install Go based on your platform.

And, below is the ‘Hello, World!’ program you can use:

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}
Syntax Description
package main      All Go programs are made up of packages. main is a special package for executable programs
import "fmt" This program is importing the package called - fmt
func main() main is a special function which is the entry point
fmt.Println Println is the exported function fmt package which prints a string

Now copy the above code and create a new file names “hello.go” and run the below command in the folder:

> go run hello.go
Hello, World!
>

If it prints “Hello, World!”, then you are all set to Go!