Setting Up a Go Development Environment: Installation, Configuration, and IDE Recommendations
This guide walks you through downloading and installing Go on Windows, macOS, and Linux, configuring essential environment variables, choosing a suitable IDE such as VS Code or GoLand, and creating and running your first Go program to verify the setup.
Go (also known as Golang) is popular for its simplicity, efficiency, and strong concurrency support. Before writing Go code, you need to set up the development environment and choose appropriate tools. This article details Go installation, environment variable configuration, and recommends several efficient IDEs/editors to get you started quickly.
1. Install Go Environment
1.1 Download Go Installer
Select the appropriate package for your operating system:
Windows: .msi installer (recommended) or .zip archive
macOS: .pkg installer or .tar.gz archive
Linux: .tar.gz archive
1.2 Install Go
Windows Installation
Double‑click the .msi file and follow the wizard (default path C:\Go ).
After installation, open Command Prompt or PowerShell and run: go version If you see something like go version go1.21.0 windows/amd64 , the installation succeeded.
macOS / Linux Installation
macOS ( .pkg ): double‑click to install, default path /usr/local/go .
Linux / macOS (manual): # Extract to /usr/local sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz
Verify the installation: go version
2. Configure Go Environment Variables
Go relies on several key environment variables:
Variable
Purpose
GOROOTInstallation path of Go (set automatically, usually no manual change needed)
GOPATHWorkspace directory for Go code, third‑party libraries, and compiled binaries (default
~/go)
GOBINDirectory for compiled executable files (usually
$GOPATH/bin)
PATHShould include
$GOROOT/binand
$GOBINso the
gocommand is globally available
2.1 Check Go Environment
go envPay special attention to GOPATH and GOBIN to ensure they point to the correct directories.
2.2 Modify GOPATH (Optional)
If you want to customize the workspace (e.g., D:\go_workspace on Windows):
Windows (PowerShell)
[System.Environment]::SetEnvironmentVariable('GOPATH', 'D:\go_workspace', 'User')macOS / Linux (Bash/Zsh)
Add the following lines to ~/.bashrc or ~/.zshrc :
export GOPATH=$HOME/go_workspace
export PATH=$PATH:$GOPATH/binThen reload the shell:
source ~/.bashrc # or source ~/.zshrc3. Choose Go Development Tools
3.1 Visual Studio Code (Recommended)
Installation steps:
Download VS Code.
Install the Go extension.
Install any additional tools prompted by the extension.
Advantages:
Lightweight and fast startup.
Powerful code completion and debugging features.
Rich plugin ecosystem.
3.2 GoLand (JetBrains)
Suitable for enterprise‑level development and large projects.
Advantages:
Intelligent code analysis.
Built‑in debugging and testing tools.
Advanced refactoring support.
3.3 Other Editors
Vim / Neovim
Emacs
Sublime Text
4. Your First Go Program
Create a file named hello.go with the following content:
package main
import "fmt"
func main() {
fmt.Println("Hello, Go!")
}Run it with:
go run hello.goThe output Hello, Go! confirms that the environment is set up correctly.
5. Summary
Install Go from the official website and verify with go version .
Configure environment variables: GOROOT , GOPATH , GOBIN , and update PATH .
Choose a development tool: VS Code (recommended), GoLand, Vim, etc.
Write and run your first program using go run hello.go .
Additional resources (promotional links):
Java learning material
C language learning material
Frontend learning material
C++ learning material
PHP learning material
php中文网 Courses
php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.