Last modified: Jan 21, 2026 By Alexander Williams
Install Go and VS Code on Windows macOS Linux
This guide helps you install Go. It also sets up VS Code. You will be ready to code.
We cover Windows, macOS, and Linux. Follow the steps for your system. It is simple.
Why Install Go?
Go is a modern programming language. It is fast and efficient. It is great for servers.
It has simple syntax. It handles many tasks at once. Many developers love it.
If you are new, learn What Is Go (Golang) and Why Use It? first. It explains the benefits well.
Step 1: Install Go on Your OS
First, download the Go installer. Visit the official Go website. Get the right version.
For Windows
Download the .msi installer. Run the file. Follow the installation wizard.
It sets the PATH for you. Check the box if asked. Restart your terminal after.
Open Command Prompt. Type go version. You should see the version.
C:\>go version
go version go1.21.0 windows/amd64
For macOS
Download the .pkg file. Open it. Follow the installation steps.
Alternatively, use Homebrew. Run brew install go in Terminal.
Open Terminal. Type go version. Confirm the installation.
$ go version
go version go1.21.0 darwin/amd64
For Linux
Use your package manager. For Ubuntu, use apt. First, remove old Go versions.
Download the tarball. Extract it to /usr/local. Set up your environment variables.
Add lines to your ~/.profile file. Then source it. Check with go version.
$ go version
go version go1.21.0 linux/amd64
Step 2: Set Up Your Workspace
Go uses a specific workspace layout. You need a GOPATH or use Go Modules.
Modern Go uses modules. Create a project directory anywhere. Initialize a module.
Open your terminal. Navigate to your project folder. Run go mod init.
$ mkdir myapp
$ cd myapp
$ go mod init example.com/myapp
go: creating new go.mod: module example.com/myapp
The go mod init command creates a go.mod file. It manages dependencies.
Step 3: Install and Configure VS Code
VS Code is a popular editor. It has excellent Go support. Download it from its website.
Install VS Code for your OS. Launch it. You need to install the Go extension.
Open the Extensions view. Search for "Go". Install the one by Go team at Google.
The extension provides many features. It offers IntelliSense and debugging.
Install Go Tools
The extension needs extra tools. VS Code will prompt you to install them.
Click "Install All" when asked. This installs gopls and others. They are vital.
If no prompt appears, open Command Palette. Run "Go: Install/Update Tools".
Select all tools. Click OK. Wait for installation to finish. Check the output panel.
Step 4: Write and Run Your First Program
Let's create a simple Go program. It will verify your setup works correctly.
In your project folder, create main.go. Add the following code. Save the file.
// main.go - A simple Go program
package main
import "fmt"
func main() {
// Print a welcome message
message := "Hello, Go World!"
fmt.Println(message)
}
To run this, use the terminal. Navigate to the file's directory. Execute go run.
$ go run main.go
Hello, Go World!
You should see the output. Your environment is now ready. You can build too.
Use go build to create an executable. Use go install to place it in GOPATH/bin.
Step 5: Essential VS Code Settings for Go
Configure VS Code for better Go development. Open Settings (JSON format).
Add these settings. They improve formatting and tool behavior. Save the file.
{
"go.useLanguageServer": true,
"go.formatTool": "goimports",
"editor.formatOnSave": true,
"go.lintTool": "golangci-lint",
}
Format on save is very useful. It keeps your code clean. Use goimports.
Consider learning more about Go's capabilities to use these tools well.
Troubleshooting Common Issues
Sometimes things go wrong. Here are quick fixes for common problems.
If go command is not found, check your PATH. Restart your terminal or computer.
For VS Code tools errors, ensure you have internet. Run the install command again.
If autocomplete fails, reload VS Code. Check if gopls is running in the background.
Conclusion
You installed Go on your operating system. You set up VS Code with the Go extension.
You created and ran a simple program. Your development environment is complete.
Go is powerful for backend and cloud services. Start building your projects now.
Explore the language further. The official Go documentation is a great resource.