f in x
Go from Scratch: Installation, Workspace, and Your First Program for Backend Developers
> cd .. / HUB_EDITORIALE
Analisi dei dati e metriche

Go from Scratch: Installation, Workspace, and Your First Program for Backend Developers

[2026-05-30] Author: Ing. Calogero Bono

You've heard Go is fast, compiled, and perfect for modern backends. But when you open the terminal, you get errors like command not found: go or go: cannot find main module. That's exactly where we at Meteora Web start — from the real problem of getting you to write your first Go program without wasting time on fluff. You don't need Go experience, but if you've used Python, Node, or Java, you'll feel at home quickly. In this guide we skip concurrency, goroutines, and channels: the basics before the basics. Clean installation, sensible workspace, working first program. In 20 minutes you'll have a functional Go environment and know exactly what you're doing.

Why Install Go (and not just 'follow the guide')

Developers coming from interpreted languages like PHP or Python often underestimate the importance of a compiler. Go is compiled: every time you run go build you get a single static executable. No runtime dependencies, no 'but it doesn't work on the server'. We at Meteora Web use it for critical services precisely for this reason: one binary to copy to the server and go. The same goes for the workspace: if you understand how Go organizes files, you never get lost. And if you make a mistake, the compiler tells you immediately, not at runtime like in JavaScript.

Installation: Choose Your Path (and verify it)

The official method is the safest: download the archive from go.dev/dl/ and follow the instructions for your system. However, we recommend using a version manager even on local machines: with gvm (Go Version Manager) or the built-in go install you can switch between versions in seconds. For us, working on multiple client projects, it's essential.

Linux / macOS with gvm

bash <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source ~/.gvm/scripts/gvm
gvm install go1.22.2
gvm use go1.22.2 --default
go version

Windows with MSI Installer

Download the .msi from go.dev, run it, restart the terminal. Then verify with go version. If you want more control, use scoop: scoop bucket add versions; scoop install go.

Verify the Installation

go env GOROOT GOPATH GOMODCACHE

If correct, you'll see paths without errors. Pay attention to GOPATH: with modern versions (Go 1.11+) you don't have to set it manually. We keep it pointing to $HOME/go and use modules for each project.

Workspace: Modules, Not Magic Folders

Before Go 1.11 you were forced to keep all code inside GOPATH/src. Not anymore: each project is an independent Go module, with its own go.mod file. This is the breakthrough that makes Go as manageable as PHP or Node. Creating a workspace is straightforward:

mkdir ~/projects/go-first
cd ~/projects/go-first
go mod init meteora/hello

The go mod init command creates a go.mod file with the module name (e.g., meteora/hello). That name can be anything, best if a URL or unique path to avoid conflicts when you publish the package. We at Meteora Web always use the form domain/client/project-name.

Minimal Project Structure

~/projects/go-first/
├── go.mod
├── main.go
└── ... other .go files

No node_modules, no vendor clutter. Each .go file belongs to a package, and the entry point is the main package with the func main() function.

First Program: Hello, METEORA!

Now that the environment is ready, let's write something concrete. Create main.go inside the project folder:

package main

import "fmt"

func main() {
	fmt.Println("Hello from Meteora Web — Go is operational!")
}

Run with go run . (the dot indicates the current module) or go run main.go. You'll see the message printed. Now compile the static executable:

go build -o hello
./hello   # on Linux/macOS; on Windows: hello.exe

You now have a single binary file — no external dependencies, no runtime to install. You can copy it to a server and run it as is. That's the superpower of Go.

Common Errors and How to Avoid Them

  • Error: package main is not a package — you forgot package main at the top of the file.
  • Error: undefined: fmt.Println — you wrote Println but didn't import "fmt". Or you imported fmt but used it in two different packages.
  • Error: no required module provides package — you didn't run go mod init in the project directory.
  • Note: go run main.go works when only main.go exists. For multiple files, use go run .

Advanced Workspace: Multiple Modules and Dependencies (overview)

For those already familiar, Go manages dependencies with go get and the go.sum file. No external package manager needed. Example to add a dependency:

go get rsc.io/quote/v4

Then in code:

import "rsc.io/quote/v4"

func main() {
	fmt.Println(quote.Go())
}

But for now, focus on a single module. Once you understand that, the rest scales.

Practical Tools for Your Workflow

  • go fmt — automatically formats code. Do it before every commit.
  • go vet — static analysis for common bugs.
  • go test — runs tests (files named *_test.go).
  • gofmt and golint (non-official but widely used).

We at Meteora Web have integrated go fmt and go vet into our CI/CD pipeline. Learn to use them from the start — they'll save you hours of debugging.

Why Workspace Matters for Italian SMEs

We often see developers installing Go 'quickly', ending up with conflicting versions, wrong paths, uninitialized modules. Then they spend an hour figuring out why go run can't find main. The problem isn't Go: it's the lack of method. We, coming from years of accounting and double-entry bookkeeping, know that a reproducible environment is like a clean balance sheet: everything adds up. That's why we invest time in configuring the workspace once and properly. Then the code flows.

In Summary — What to Do Next

  1. Install Go using the official method or gvm. Verify with go version.
  2. Create a module: mkdir my-project && cd my-project && go mod init my/domain.
  3. Write your first program in main.go with package main and func main.
  4. Run with go run . and compile with go build.
  5. Add to your workflow go fmt and go vet.

If you want to dive deeper into managing your code with Git, we have a practical Git guide for beginners that pairs perfectly with this setup. Happy coding.

Sponsored Protocol

Ing. Calogero Bono

> AUTHOR_EXTRACTED

Ing. Calogero Bono

Co-founder di Meteora Web. Ingegnere informatico, sviluppo ecosistemi digitali ad alte prestazioni. AI, automazione, SEO tecnica e infrastrutture web. Scrivo di tecnologia per rendere complesso… semplice.

[ Read Full Dossier ]

Hai bisogno di applicare questa strategia?

Esegui il protocollo di contatto per iniziare un progetto con noi.

> INIZIA_PROGETTO

Sponsored

> MW_JOURNAL

> READ_ALL()