Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 2 of 60 · Go

Installing Go & Setting Up the Workspace

Duration: 15 minutes

Installing Go & Setting Up the Workspace

This lesson explains how to install Go on Windows, macOS, and Linux, then create a simple module and understand the basic workspace structure.

Install Go

Windows

  1. Go to https://go.dev/dl/ and download the Windows MSI installer.
  2. Run the installer and accept the default installation location.
  3. Open PowerShell and verify the installation:
go version
  1. Check that Go is on your PATH and that the install location is correct:
go env GOROOT
go env GOPATH
go env GO111MODULE

If go version does not work, open Windows Settings, search for Environment Variables, and add C:\Go\bin to the PATH. Then restart PowerShell.

macOS

  1. Download the macOS package from https://go.dev/dl/ and run the installer.
  2. Open Terminal and verify:
go version
  1. If the command is not found, add Go to your shell PATH:
export PATH="$PATH:/usr/local/go/bin"

Then restart your terminal or source your shell profile.

Linux

  1. Download the Linux tarball from https://go.dev/dl/.
  2. Extract it to /usr/local:
sudo tar -C /usr/local -xzf go1.22.linux-amd64.tar.gz
  1. Add Go to your PATH:
export PATH="$PATH:/usr/local/go/bin"
  1. Verify the installation:
go version

Modules and Workspace Basics

Go uses modules to manage dependencies and versions. A module is a collection of packages with a go.mod file at its root. Modules allow your code to live anywhere on disk, not just inside GOPATH.

Create a new project directory and initialize a module:

mkdir hello-go
cd hello-go
go mod init github.com/yourname/hello-go

Create main.go:

package main

import "fmt"

func main() {
    fmt.Println("Hello from your first Go module!")
}

Run the project:

go run main.go

Build a reusable binary:

go build

This produces an executable named hello-go on macOS/Linux or hello-go.exe on Windows. Use go env to inspect your Go configuration and verify your module is active.

Info

When you initialize a module, go.mod records the module path and Go version. You only need to set GOPATH manually in rare cases.

Previous: Welcome & Course OverviewNext: Basic Syntax: Packages, Functions, and Variables