Get Started #
To start using Go, you need two things:
- A text editor, like VS Code, to write Go code
- A compiler, like GCC or Go toolchain, to translate Go code into machine-readable code.
There are many editors and compilers available, but in this tutorial, we will use an IDE for ease of use.
✅ Go Install #
👉 Download the latest Go installation files here:
https://golang.org/dl/
Follow the installation instructions for your operating system.
After installation, verify by running in a terminal:
go version
Expected output example:
go version go1.20.0 windows/amd64
✅ Go IDE Installation #
An IDE (Integrated Development Environment) helps you edit, compile, and debug your Go code.
Popular free IDEs for Go:
- Visual Studio Code (VS Code)
- Vim
- Eclipse
- Notepad++
ℹ️ Web-based IDEs can work but have limited functionality.
For this tutorial, we will use VS Code.
👉 Download VS Code here: https://code.visualstudio.com/
✅ Configure VS Code for Go #
- Launch VS Code.
- Open the Extensions Manager (or press
Ctrl + Shift + X
). - Search for the official Go extension by the Google Go team and install it.
- After installing, open the Command Palette (
Ctrl + Shift + P
). - Run the command:
Go: Install/Update Tools
- Select all the tools and click OK.
Now, VS Code is ready to develop Go applications.
✅ Quickstart: First Go Program #
Step 1: Initialize a Go Module #
Open the terminal in VS Code and type:
go mod init example.com/hello
Don’t worry if you don’t understand this yet—it will be explained later.
Step 2: Create the Hello World Program #
Create a new file in VS Code:
File > New File
→ Save as helloworld.go
Paste the following code:
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}
Step 3: Run Your Program #
In the terminal, execute:
go run .\helloworld.go
Expected output:
Hello World!
🎉 Congratulations! You have written and run your first Go program.
✅ Optional: Build Executable #
To save the program as a standalone executable, run:
go build .\helloworld.go
This will generate a helloworld.exe
you can run directly.