The Go environment is the set of tools for compiling and running Go programs on our computer.
In the previous article, we saw what Go is and why it makes sense to learn it. Now comes the fun part: installing the language, preparing the editor, and writing the first program.
The good news is that Go comes quite well packaged. We don’t have to set up a fair of dependencies or fight with twenty different installers. We install Go, check it works, and start coding.
Installing Go
Let’s prepare the ground. Installing Go is very simple.
Go to the official page go.dev/dl.
Download the installer corresponding to your operating system (Windows, macOS, or Linux).
Run the installer and follow the steps.
Once finished, we need to check that everything went well. Open a terminal (or command console) and type:
go versionYou should see something similar to this (the version number and architecture will vary depending on your machine):
go version go1.26.5 windows/amd64Done! We now have the Go compiler and tools installed.
Configuring VS Code
Although you can write Go with any text editor, we will use Visual Studio Code. It’s lightweight, free, and has excellent Go support.
To configure it:
Open VS Code.
Go to the Extensions tab (or press Ctrl+Shift+X).
Search for “Go”.
Install the official Go extension developed by the Go Team at Google.
The first time you open a .go file, VS Code will likely ask you to install additional tools (gopls, dlv, staticcheck…). Say yes to everything (Install All). These are important tools for autocompletion, formatting, and debugging.
Our First Hello World
Let’s write our first program to make sure everything works and understand the basic flow.
Create a folder for your project.
Open that folder with VS Code.
Open the integrated terminal in VS Code (Ctrl + ñ or Terminal > New Terminal).
Before writing code, we initialize a module. This creates a go.mod file, which identifies the module and records its dependencies when we have them.
Run in the terminal:
go mod init hello-worldNow create a file called main.go and write the following:
package main
import "fmt"
func main() {
fmt.Println("Hello world from LuisLlamas.es!")
}Quick Analysis
package main: every Go file belongs to a package.mainis special: it tells the compiler that this code is an executable program, not a library.import "fmt": we import thefmtpackage from the standard library to write text to the console.func main(): this is the entry point function. The program starts here.
Running the Program
We have two common ways to run this.
Direct Execution
For development, we use go run. It compiles and runs in a single step, but does not leave a final executable in the folder.
go run main.goOutput:
Hello world from LuisLlamas.es!Compilation
To generate a binary, we use go build.
go buildThis will generate an executable in the project folder. On Windows it will be something like hello-world.exe; on Linux or macOS, simply hello-world.
The generated executable is self-contained. You don’t need to install Go on the machine where you will run it, as long as you compiled it for that operating system.
Now we have everything ready: Go installed, VS Code configured, a module created, and a first program working.