While Go is a nice language to use, there is a bit of ceremony to setting things up and compiling.
This guide assumes that you have successfully installed Go. It can be downloaded from
go.dev
This is where your source code will live. For this example make a folder called 'Hello World'.
Open a command prompt inside the folder you have just created and type 'go mod init hello'. This creates an init file which is used to set your program's Go version and any dependencies. In this case it means our exe output file will be called 'hello'.
C:\Hello World>go mod init hello go: creating new go.mod: module hello
A nice simple 'Hello World' program. Save this as hello.go into the folder created above.
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello World!")
}
To compile the program, use a command prompt inside the Hello World folder and type go build
C:\Hello World>go build C:\Hello World>
If everything was successful, there are no messages. If you have any errors, go correct them and try again!
The program compiled to hello.exe so we can run it as follows:
C:\Hello World>hello Hello World!
You should have now made and run your first Go program!
Updated (06/08/2026)