codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🐹

Go (Golang)

2 / 72 topics
1Introduction to Go (Golang)2Installation and Setup3Hello World Program4Variables and Constants5Data Types6Operators7Control Structures (if, else, switch)8Functions9Defer Statement10Panic and Recover
Tutorials/Go (Golang)/Installation and Setup
🐹Go (Golang)

Installation and Setup

Updated 2026-04-20
4 min read

Installation and Setup

Introduction

Go, also known as Golang, is a statically typed, compiled language developed by Google. It's designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. The language was first introduced in 2009 and has since become popular for its simplicity, efficiency, and strong support for concurrent programming.

This tutorial will guide you through the installation and setup process of Go on your system. We'll cover various operating systems including Windows, macOS, and Linux. Additionally, we'll explore setting up your development environment and writing your first Go program.

Prerequisites

Before proceeding with the installation, ensure that your system meets the following requirements:

  • A computer running one of the supported operating systems: Windows (10/11), macOS (10.15+), or Linux.
  • An internet connection to download the Go binaries.
  • Basic knowledge of command-line interfaces.

Installation Steps

1. Downloading Go

Go provides official binary distributions for various operating systems and architectures. You can download the latest version from the official Go website.

Windows

  1. Visit the downloads page and select the appropriate installer for your system (e.g., go1.x.x.windows-amd64.msi).
  2. Run the downloaded .msi file and follow the installation wizard.

macOS

  1. Download the .pkg file from the downloads page.
  2. Open the downloaded .pkg file and follow the installation instructions.

Linux

  1. Download the appropriate .tar.gz file for your system (e.g., go1.x.x.linux-amd64.tar.gz) from the downloads page.

  2. Extract the tarball to /usr/local, creating a Go tree in /usr/local/go:

    sudo tar -C /usr/local -xzf go1.x.x.linux-amd64.tar.gz
    

2. Setting Up Environment Variables

After installation, you need to set up the environment variables to use Go commands from your terminal.

Windows

  1. Open the Start Menu and search for "Environment Variables".
  2. Click on "Edit the system environment variables".
  3. In the System Properties window, click on the "Environment Variables" button.
  4. Under "System variables", click "New" and add a new variable named GOROOT with the value of your Go installation directory (e.g., C:\Go).
  5. Find the Path variable under "System variables" and click "Edit".
  6. Add a new entry %GOROOT%\bin.

macOS/Linux

  1. Open your terminal.

  2. Edit your shell configuration file (~/.bashrc, ~/.zshrc, etc.) using a text editor:

    nano ~/.bashrc
    
  3. Add the following lines at the end of the file:

    export GOROOT=/usr/local/go
    export PATH=$PATH:$GOROOT/bin
    
  4. Save the file and apply the changes by running:

    source ~/.bashrc
    

3. Verifying Installation

To verify that Go is installed correctly, run the following command in your terminal:

go version

You should see output similar to go version go1.x.x windows/amd64 or go version go1.x.x darwin/amd64, depending on your operating system.

Setting Up Your Development Environment

1. Installing an IDE/Text Editor

While you can use any text editor, it's recommended to use an Integrated Development Environment (IDE) that provides Go-specific features like syntax highlighting, code completion, and debugging.

Popular choices include:

  • Visual Studio Code: With the Go extension.
  • JetBrains GoLand.
  • IntelliJ IDEA with Go plugin.

2. Configuring Your IDE

Most modern IDEs will automatically detect Go installations and configure themselves accordingly. However, you may need to manually set the GOROOT and GOPATH environment variables in your IDE settings.

Visual Studio Code

  1. Open VSCode.
  2. Install the Go extension from the marketplace.
  3. Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and type "Go: Install/Update Tools".
  4. Follow the prompts to install necessary tools like gopls, goimports, etc.

Writing Your First Go Program

Now that you have Go installed and your environment set up, let's write a simple "Hello, World!" program.

  1. Create a new directory for your Go projects:

    mkdir ~/go-projects
    cd ~/go-projects
    
  2. Create a new file named hello.go:

    nano hello.go
    
  3. Add the following code to hello.go:

    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("Hello, World!")
    }
    
  4. Save the file and run it using the Go command:

    go run hello.go
    

You should see the output Hello, World! in your terminal.

Best Practices

  • Use Modules: Since Go 1.11, modules are the recommended way to manage dependencies. Initialize a new module by running go mod init <module-name> in your project directory.

  • Keep Your Code Organized: Use packages effectively to organize your code. Each package should have a clear responsibility.

  • Write Tests: Go has built-in support for testing. Write unit tests for your functions using the testing package.

  • Use Linters and Formatters: Tools like golangci-lint can help you maintain clean and error-free code. Use formatters like goimports to automatically format your code.

Conclusion

You have successfully installed Go on your system, set up your development environment, and written your first Go program. This is just the beginning of your journey with Go. As you progress, you'll explore more advanced features and best practices that will help you write efficient and maintainable Go applications.

Remember to keep learning and experimenting with Go's rich ecosystem of tools and libraries. Happy coding!


PreviousIntroduction to Go (Golang)Next Hello World Program

Recommended Gear

Introduction to Go (Golang)Hello World Program