Go Getting Started Guide

Su Suriya Ravichandran Updated 13 Sep 2026
4 min read ·Lesson 2 of 12

Getting started with Go is simple: install the toolchain, pick an editor, initialize a project, and run your first program. This guide walks through each step in order.

What You Need to Start with Go

You need two things: a code editor, and the Go toolchain itself.

1. Code Editor or IDE

Any text editor works, but these are the most common choices in the Go community:

  • Visual Studio Code (VS Code) — free, beginner-friendly, and has an official Go extension. This is the recommended choice for most learners.
  • GoLand — a full-featured, Go-specific IDE from JetBrains (paid, with a free trial).
  • Vim / Neovim — lightweight and highly configurable, popular with experienced developers.

2. The Go Toolchain

Unlike C or C++, where you typically install a compiler separately from your editor, Go ships as a single toolchain that includes the compiler, formatter, dependency manager, and test runner — all accessed through the go command.

Installing Go

  1. Visit the official downloads page: https://go.dev/dl/
  2. Download the installer for your operating system (Windows, macOS, or Linux).
  3. Run the installer and follow the setup instructions.
  4. Verify the installation by opening a terminal and running:
go version

Expected output (the exact version number will differ):

go version go1.23.0 darwin/arm64

If a version number is printed, Go is installed correctly.

Note: The official Go download and documentation domain is go.dev (with golang.org still redirecting there). Using go.dev/dl/ avoids relying on the older domain.

Setting Up VS Code for Go Development

  1. Download and install VS Code from https://code.visualstudio.com/.
  2. Open VS Code.
  3. Go to the Extensions panel (Ctrl+Shift+X on Windows/Linux, Cmd+Shift+X on macOS).
  4. Search for "Go" and install the official extension published by the Go Team at Google.
  5. Open any .go file, or open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run Go: Install/Update Tools.
  6. Select all the listed tools and click OK. VS Code will download supporting tools such as gopls (the Go language server), which powers autocomplete, go-to-definition, and inline error checking.

Your environment is now fully configured for Go development.

Go Project Initialization

Before writing code, initialize a Go module. A module tracks your project's dependencies and gives your code an import path, similar to how package.json works in a Node.js project.

go mod init example.com/myapp

This creates a go.mod file in your project folder — a small text file that records the module's name and the Go version it targets. Every standalone Go project should start with this step.

Your First Go Program

Step 1: Create a New File

Create a file named main.go inside your project folder.

Step 2: Add the Following Code

package main

import "fmt"

func main() {
    name := "Developer"
    fmt.Println("Hello,", name, "! Welcome to Go.")
}

Step 3: Run the Program

go run main.go

Expected output:

Hello, Developer ! Welcome to Go.

go run compiles the program to a temporary binary, executes it immediately, and then discards the binary. It's the fastest way to test code while developing.

Note on spacing: fmt.Println inserts a space between every argument, which is why the output above reads Developer ! with a space before the exclamation mark rather than Developer!. If you want the punctuation attached directly to the name, concatenate the strings instead: fmt.Println("Hello, " + name + "! Welcome to Go.").

Building an Executable

go run is convenient for development, but for deployment you want a standalone binary:

go build main.go

This produces a compiled binary:

  • On Windows → main.exe
  • On macOS/Linux → main

You can run this file directly, on any machine with a matching operating system and architecture, without installing Go or any other dependency:

./main

Bonus Example: A Simple Calculator

package main

import "fmt"

func main() {
    var a, b int = 10, 5

    sum := a + b
    difference := a - b
    product := a * b
    quotient := a / b

    fmt.Println("Sum:", sum)
    fmt.Println("Difference:", difference)
    fmt.Println("Product:", product)
    fmt.Println("Quotient:", quotient)
}

Expected output:

Sum: 15
Difference: 5
Product: 50
Quotient: 2

Notice that quotient prints 2, not 2.0 — both a and b are integers, so / performs integer division and discards the remainder. This is a frequent source of bugs for beginners coming from languages where division always returns a decimal; the Data Types and Operators lessons cover this in more depth.

Tips for Beginners

  • Always run go mod init when starting a new project — many go commands and third-party tools expect a go.mod file to be present.
  • Keep related source files inside a single project folder.
  • Use go run while developing and testing, and go build when you're ready to produce a binary for distribution.
  • Run gofmt (or let your editor run it automatically on save) to keep your code consistently formatted — Go's tooling treats formatting as a solved problem, not a style debate.
  • Browse the standard library documentation at https://pkg.go.dev/std — a large share of what you'll need (HTTP, JSON, file I/O, time) is already built in.

What You've Accomplished

By this point you have:

  • Installed Go and verified the installation
  • Configured VS Code for Go development
  • Initialized a Go module
  • Written, run, and compiled your first Go program

0 Comments

Reviewed before they appear

No comments yet.

Go Lang
Ask about this post
AI Ask about this post

Ask questions about Go Getting Started Guide and get answers drawn from it.

Signed-in readers only.