DEV Community

Romulo Gatto
Romulo Gatto

Posted on

Introduction to Go: Installation and Setup

Introduction to Go: Installation and Setup

Go, also known as Golang, is an open-source programming language developed by Google. It is known for its simplicity, efficiency, and strong support for concurrency. Whether you're a beginner or an experienced developer looking to explore Go, this guide will walk you through the installation process and help you get your development environment set up.

Before You Begin

Before we dive into installing Go on your machine, it's important to ensure that your system meets the requirements.

Go has specific hardware requirements based on the operating system you are using:

  • For Windows users:

    • A CPU with Intel x86-64 architecture since Go's binary distribution targets this architecture.
    • At least 2GB RAM.
  • For macOS users:

    • An Intel-based Mac with at least OS X Yosemite (10.10) or later versions installed.
  • For Linux users:

    • Various distributions of Linux are supported by Go including Ubuntu, Debian, Fedora, etc., as long as they meet the minimum kernel version requirement of GNU/Linux 2.6.23.

Make sure your system fulfills these requirements before proceeding with the installation steps.

Step 1: Downloading and Installing Go

Download the latest stable version of Go from the official website (https://golang.org/dl/). The website automatically detects your operating system and offers you a downloadable package tailored for it.

Once downloaded:

  1. For Windows: Double-click on the executable file (.msi) you just downloaded and follow the installation wizard.

  2. For macOS: Double-click on the .pkg file in your Downloads folder to start installation; then follow the prompts shown in the installer window.

  3. For Linux: Open the Terminal application (Ctrl + Alt + T), and navigate to where you have downloaded/extracted tar.gz archive containing go binaries using the cd command.

   cd path-to-extracted-folder
Enter fullscreen mode Exit fullscreen mode

Once there, run the following command to install Go:

   sudo ./bin/go_installer.sh
Enter fullscreen mode Exit fullscreen mode

With these steps, you should have Go successfully installed on your computer.

Step 2: Setting Up GOPATH and Workspace

Go requires a specific directory structure for organizing your projects. Let's set up the GOPATH environment variable and workspace.

  1. Create a directory that will serve as your workspace. This is where you'll store all your Go projects.

  2. Set the GOPATH environment variable to point to this workspace directory.

For Windows users, follow these steps:

  • Right-click on "This PC" or "My Computer" and select "Properties".

  • Click on "Advanced system settings" from the left sidebar.

  • In the System Properties window, click on "Environment Variables".

  • Under "User variables", click on "New".

  • Enter GOPATH for the variable name and provide the path to your workspace directory (e.g., C:\Users\YourUsername\go) as its value.

For macOS/Linux users, open Terminal app (Ctrl + Alt + T) and type in:

export GOPATH=path/to/your/workspace/directory
Enter fullscreen mode Exit fullscreen mode

Now that we have set up our workspace, we can start writing our first Go program!

Conclusion

In this guide, we walked through how to install Go on Windows, macOS, and Linux systems. We also covered setting up the necessary environment variables Go requires for organizing our projects within a defined workspace. With everything set up correctly, you're ready to dive into programming with Go!

Remember that practice makes perfect when it comes to learning any new language or technology. Feel free to explore more about what Go has to offer by checking out the official Go documentation and experimenting with your projects. Happy coding!

Top comments (0)