Go is designed to be simple to install and fast to build. This guide covers running, debugging and building Go in VS Code.

Install Go

  • All platforms: download the installer from go.dev/dl.
  • macOS: brew install go.
  • Linux: extract the official tarball to /usr/local and add /usr/local/go/bin to your PATH.

Verify: go version

VS Code

Install the official Go extension by the Go Team. The first time you open a Go file it will offer to install helper tools (gopls for IntelliSense, dlv for debugging) — accept.

Create and run a module

go mod init hello

Create main.go:

package main

import "fmt"

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

Run it:

go run .

Debug it

The Go extension uses Delve. Set a breakpoint, press F5 and choose the default Go launch configuration. You can step through goroutines and inspect variables live.

Build a binary

go build -o hello .
./hello

Go produces a single statically linked executable with no runtime to install. Cross-compile for other systems by setting environment variables, e.g. GOOS=windows GOARCH=amd64 go build.