Daily Tech Brief

Top startup stories in your inbox

Subscribe Free

© 2026 rakrisi Daily

Go Programming Setup for Beginners - Complete Installation Guide

Setting up Your Go Environment

Welcome to your second lesson! By now you understand what Data Structures and Algorithms are. Now it’s time to set up your computer so you can start writing code. Don’t worry - this is like setting up a new kitchen before cooking. We’ll go through it step by step.

What is Go?

Go (also called Golang) is a programming language created by Google. Think of it as a special language that computers understand. Just like you speak English to communicate with people, you use Go to communicate with computers.

Why Go for learning DSA?

  • Simple: Easy to read and write, like speaking clearly
  • Fast: Runs quickly, like a sports car
  • Reliable: Doesn’t crash easily, like a well-built car
  • Popular: Used by big companies like Google, Netflix, and Uber

Step 1: Installing Go

For Windows Users

  1. Open your web browser (like Chrome, Firefox, or Edge)
  2. Go to the Go website: Visit https://golang.org/dl/
  3. Download the installer: Look for “Windows Installer” and click download
  4. Run the installer: Double-click the downloaded file
  5. Follow the instructions: Click “Next” through all the steps
  6. Important: Make sure to check the box that says “Add Go to PATH”

What is PATH? It’s like telling Windows where to find Go, so you can use it from anywhere.

For Mac Users

  1. Open Terminal (press Command + Space, type “Terminal”, press Enter)
  2. Install Homebrew (if you don’t have it):
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. Install Go:
    brew install go

For Linux Users

  1. Open Terminal
  2. Update your system:
    sudo apt update
  3. Install Go:
    sudo apt install golang-go

Step 2: Verifying Installation

Let’s make sure Go is installed correctly.

Open Command Prompt/Terminal

Windows: Press Windows key + R, type “cmd”, press Enter Mac: Press Command + Space, type “Terminal”, press Enter Linux: Press Ctrl + Alt + T

Check Go Version

Type this command and press Enter:

go version

You should see something like:

go version go1.21.0 windows/amd64

If you see an error, Go is not installed correctly. Try reinstalling.

Step 3: Setting up Your Workspace

Create a Folder for Your Code

  1. Create a new folder on your desktop called “go-dsa”
  2. Open Command Prompt/Terminal and navigate to this folder:

Windows:

cd Desktop
cd go-dsa

Mac/Linux:

cd Desktop
cd go-dsa

Initialize Your Go Project

Type this command:

go mod init dsa-course

This creates a file called go.mod that tells Go this is a Go project.

Step 4: Your First Go Program

Create Your First File

  1. Open a text editor (Notepad on Windows, TextEdit on Mac, or any code editor)
  2. Create a new file called main.go
  3. Type this code:
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
    fmt.Println("Welcome to DSA with Go!")
    
    // Let's do some basic math
    a := 10
    b := 20
    sum := a + b
    
    fmt.Printf("%d + %d = %d\n", a, b, sum)
}

Understanding the Code

Let’s break down what each line does:

package main

This tells Go that this is the main program file.

import "fmt"

This brings in the “fmt” package, which helps us print text. “fmt” stands for “format”.

func main() {

This defines the main function - where our program starts running.

fmt.Println("Hello, World!")

This prints “Hello, World!” to the screen.

a := 10
b := 20
sum := a + b

This creates variables a and b with values 10 and 20, then adds them together.

fmt.Printf("%d + %d = %d\n", a, b, sum)

This prints the math problem and answer. The %d are placeholders for numbers.

}

This closes the main function.

Run Your Program

In your terminal/command prompt (make sure you’re in the go-dsa folder), type:

go run main.go

You should see:

Hello, World!
Welcome to DSA with Go!
10 + 20 = 30

Congratulations! You just wrote and ran your first Go program! 🎉

Step 5: Understanding Go Basics

Before we dive into DSA, let’s learn some basic Go concepts.

Variables

Variables are like containers that hold data. Think of them as labeled boxes.

// Different ways to declare variables
var age int = 25          // Explicit type
var name string = "Alice" // String type
count := 10               // Go infers the type (int)
price := 99.99            // Go infers float64

Data Types

Go has different types of data, like different sizes of containers:

// Numbers
var wholeNumber int = 42        // Integers: -2, -1, 0, 1, 2, ...
var decimalNumber float64 = 3.14 // Decimals: 1.5, 2.7, 3.14159, ...

// Text
var greeting string = "Hello"   // Text in quotes

// True/False
var isStudent bool = true       // Only true or false

// Collections
var numbers []int = []int{1, 2, 3, 4, 5}  // List of numbers

Functions

Functions are like recipes - they take ingredients (inputs) and produce results (outputs).

// Function that adds two numbers
func addNumbers(a int, b int) int {
    return a + b
}

// Function that greets someone
func greet(name string) {
    fmt.Printf("Hello, %s!\n", name)
}

// Using the functions
result := addNumbers(5, 3)  // result = 8
greet("Alice")              // Prints: Hello, Alice!

Loops

Loops repeat code multiple times, like doing jumping jacks.

// Count from 1 to 5
for i := 1; i <= 5; i++ {
    fmt.Printf("Count: %d\n", i)
}

// Loop through a list
fruits := []string{"apple", "banana", "orange"}
for index, fruit := range fruits {
    fmt.Printf("%d: %s\n", index+1, fruit)
}

Conditions

Conditions let your program make decisions, like choosing what to wear based on weather.

temperature := 25

if temperature > 30 {
    fmt.Println("Wear light clothes")
} else if temperature > 20 {
    fmt.Println("Wear normal clothes")
} else {
    fmt.Println("Wear warm clothes")
}

Step 6: Installing a Code Editor

While you can use any text editor, a code editor makes programming much easier.

  1. Download VS Code: Go to https://code.visualstudio.com/
  2. Install it on your computer
  3. Install Go extension:
    • Open VS Code
    • Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac)
    • Type “Extensions: Install Extensions”
    • Search for “Go” and install the official Go extension

Why VS Code?

  • Free: Costs nothing
  • Smart: Helps you write code with suggestions
  • Go Support: Understands Go code and helps fix errors
  • Easy to Use: Simple interface

Step 7: Testing Your Setup

Let’s create a more advanced test program to make sure everything works.

Create a new file called test.go:

package main

import "fmt"

func main() {
    // Test basic operations
    fmt.Println("=== DSA Setup Test ===")
    
    // Test variables and math
    x := 15
    y := 7
    fmt.Printf("%d + %d = %d\n", x, y, x+y)
    fmt.Printf("%d - %d = %d\n", x, y, x-y)
    fmt.Printf("%d * %d = %d\n", x, y, x*y)
    fmt.Printf("%d / %d = %d\n", x, y, x/y)
    
    // Test arrays (we'll learn about these soon!)
    numbers := []int{1, 2, 3, 4, 5}
    fmt.Println("Numbers:", numbers)
    
    // Test loops
    fmt.Println("Counting:")
    for i := 1; i <= 3; i++ {
        fmt.Printf("  %d\n", i)
    }
    
    // Test conditions
    score := 85
    if score >= 90 {
        fmt.Println("Grade: A")
    } else if score >= 80 {
        fmt.Println("Grade: B")
    } else {
        fmt.Println("Grade: C")
    }
    
    fmt.Println("=== Setup Complete! ===")
}

Run it with:

go run test.go

Common Problems and Solutions

Problem: “go command not found”

Solution: Go is not in your PATH. Try reinstalling and make sure to check “Add to PATH”.

Problem: “go.mod file not found”

Solution: Make sure you’re in the correct folder and have run go mod init.

Problem: Code doesn’t run

Solution: Check for typos. Go is very strict about spelling and punctuation.

Problem: Confusing error messages

Solution: Read error messages carefully. They usually tell you exactly what’s wrong.

What We’ve Accomplished

By completing this lesson, you now have:

✅ Go installed on your computer ✅ A working development environment ✅ Basic understanding of Go syntax ✅ Your first programs running successfully ✅ A code editor set up for programming

Next Steps

In the next module, we’ll start learning about Arrays and Strings - your first data structures! You’ll learn:

  • How to store multiple items in order
  • How to access and modify data quickly
  • Basic operations like searching and sorting

Remember: Programming is like learning a new language. It takes practice, but every expert was once a beginner. You’re doing great!

Ready to learn about arrays? Let’s go to the next module!