Install Go and run your first program

Learn Go · Beginner · 8 min

How do you get from nothing to a running Go program?

  1. 1Guess

    package main
    
    import "fmt"
    
    func main() {
    	fmt.Println("Hello")
    	fmt.Println("Go", "world")
    }
    
    What does this program print?
  2. 2Read

    Install Go

    Download the installer for your system from go.dev/dl and run it. Then open a new terminal and type go version. It prints the installed version, which tells you the install worked. The Go command is the one tool you use for everything in this course: it runs, builds and tests your code.

  3. 3Read

    Make a module

    A module is a folder of Go code with a go.mod file. Create it with go mod init example/hello; the name is the module path. Then go run . builds the program in the current folder and runs it. go build compiles the program and leaves an executable file, but does not run it.

  4. 4Code

    A first program with Println and Printf

    1 / 2
    package main
    
    import "fmt"
    
    func main() {
    	name := "Ada"
    	age := 36
    	fmt.Println("Hello, Go")
    	fmt.Printf("%s is %d years old\n", name, age)
    }
    

    Read the program. What will it print?

    Run it in the playground

  5. 5Read

    What package main means

    The first line, package main, says this code builds into a program. func main() is the function Go calls first. import "fmt" makes the fmt package available; its name comes before the dot, as in fmt.Println. A file that does not start with a package clause is not valid Go.

  6. 6Say it back

  7. 7Mission · 8 min

    Install Go, check the version, make a hello folder with a module in it, write the first program into main.go and run it.

    go version
    mkdir hello && cd hello
    go mod init example/hello
    go run .

Common questions

How do I install Go?
Download the installer for your operating system from go.dev/dl, run it, then open a new terminal and type go version. If it prints a version number, Go is installed and ready. You do not need an editor plugin or extra tools for the first lessons: a plain text editor and a terminal are enough to write, run and change small programs.
What is a Go module?
A module is a folder of Go code described by a go.mod file, which records the module path and the modules the code depends on. You create one with go mod init and a name such as example/hello. Once the file exists, commands like go run . and go build work from that folder without further setup.
What is the difference between go run and go build?
The go run command compiles your program and starts it at once, which is handy while you learn or test an idea. The go build command compiles the program and leaves an executable file in the folder, without running it. Use build when you want to keep or share the compiled program, and run when you only want the result.

Sources

Measured with go1.27.4 darwin/arm64 on 2026-12-03

Published Dec 3, 2026 · Updated Dec 3, 2026

Never miss new offers and news

New tools, credits, and AI news are added regularly. Pick how you want to hear about them.

Telegram channel

Join @aifree_dev and get new free AI offers and news right in your Telegram feed.

Browser notifications

Turn on push notifications and get an alert on this device whenever something new is posted. No account needed.

Email newsletter

A weekly digest of new, changed and expiring free AI offers. Double opt-in, one-click unsubscribe. See the latest issue.

Unsubscribe anytime. Privacy

Frequently asked questions

What is aifree.dev?

aifree.dev helps everyone access AI through a curated directory of free AI tools, API credits, free tiers, and startup programs for coding, image, voice, video, and students - verified regularly.

How are offers presented?

Each offer includes its access details, free models when available, and expiration information when provided. Limited-time deals stay visible so they are easy to compare.

Do education and startup programs need verification?

Yes. Providers usually ask students to verify their status with a school email, student ID, or a program like the GitHub Student Pack, and ask startups to verify company details such as age, funding, or website. Check each offer’s claim page for the exact requirements.

What kinds of free AI offers are listed?

Free tiers and free trials from AI providers, free API credits, startup and student programs, and free tools for coding, image generation, voice, and video.

How can I suggest a tool or report a broken link?

Use the submit form: paste the offer page URL and a short note. A person checks every submission before anything is listed. Broken links and changed terms go through the same form.

Know a good one?

Tell us about an AI tool worth knowing. Found a broken link? We want to hear that too.

Submit an offer