Featured image of post Install Go and Run Your First Program

Install Go and Run Your First Program

Install Go on Windows, macOS, or Linux, verify it with go version, create a module, and run a Hello World program.

About Go

Go began at Google and is now developed as an open-source project. It is a statically typed, compiled language. Go supports pointers, but not pointer arithmetic. Its runtime includes a garbage collector.

Install Go

Open the official download and installation guide and choose the instructions for your operating system (Windows, macOS, or Linux) and CPU architecture. Follow the official steps, then open a new terminal and run:

1
go version

If the command prints a version, the go command is available. When updating Go, follow the official replacement instructions instead of unpacking a new version over an existing installation. See Managing Go installations for version management.

Run Hello, World

Create a working directory and initialize a module inside it:

1
2
3
mkdir hello
cd hello
go mod init example/hello

Create hello.go in that directory and save this code:

1
2
3
4
5
6
7
package main

import "fmt"

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

Run the program with:

1
go run .

It prints Hello, World!. To build an executable, run go build. The output name and extension depend on the operating system; Windows executables normally use .exe.

Continue learning

The official introductory materials are primarily available in English.

Licensed under CC BY-NC-SA 4.0
Last updated on 2026/11/23 00:00 UTC
comments powered by Disqus