Chapter 3: Go Getting Started
What “Getting Started with Go” Actually Is
- Goal: Get Go installed → write/run first code → understand modules (modern dependency system) → call code from an external library.
- Time: 10–20 minutes if you follow along.
- Teaches: go command basics, go.mod, go run, importing third-party modules, pkg.go.dev discovery.
- Current as of Feb 2026: Works with Go 1.26.0 (latest stable from go.dev/dl — released late 2025 / early 2026).
Step 0: Install Go (if not done yet)
Go to https://go.dev/dl → download Go 1.26.0 (or newer if a patch dropped today).
-
Linux (most common in Hyderabad dev setups):
Bash01234567wget https://go.dev/dl/go1.26.0.linux-amd64.tar.gzsudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.26.0.linux-amd64.tar.gzAdd to PATH (put in ~/.bashrc or ~/.zshrc):
Bash01234567export PATH=$PATH:/usr/local/go/binsource ~/.bashrc -
macOS: Use the .pkg installer or Homebrew (brew install go).
-
Windows: .msi installer → it adds to PATH automatically.
Verify:
|
0 1 2 3 4 5 6 7 |
go version # Should show: go version go1.26.0 linux/amd64 (or windows/amd64, darwin/arm64 etc.) |
Step 1: Create Your First Project Folder
Open terminal (PowerShell / cmd on Windows, or bash/zsh):
|
0 1 2 3 4 5 6 7 8 9 10 |
# Go to your home (or any folder you like — no GOPATH needed anymore!) cd mkdir hello cd hello |
→ Why a new folder? Go projects live in directories. Each directory = one package.
Step 2: Initialize a Go Module (Super Important — 2026 Standard)
|
0 1 2 3 4 5 6 |
go mod init example/hello |
Output:
|
0 1 2 3 4 5 6 |
go: creating new go.mod: module example/hello |
→ A file go.mod appears:
|
0 1 2 3 4 5 6 7 8 |
module example/hello go 1.26 |
Why this matters:
- Before Go 1.11 → code had to live in $HOME/go/src/…
- Now → anywhere. Modules let Go track dependencies + versions.
- example/hello is a fake path (for local learning). Real projects use github.com/webliance/myapp.
Step 3: Write Your First Go File — hello.go
Create file hello.go (use VS Code — install Go extension by Go Team at Google — it auto-formats + gives hints).
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 |
package main import "fmt" func main() { fmt.Println("Hello from Hyderabad, Telangana! 🇮🇳") fmt.Println("Getting Started with Go — Feb 2026 🚀") } |
Key lines explained:
- package main → This package can have a main() function → becomes executable.
- import “fmt” → Standard library package for printing.
- func main() → Program starts here (like public static void main in Java).
Step 4: Run It! (Easiest Way)
|
0 1 2 3 4 5 6 |
go run . |
(. means “current directory”)
Output:
|
0 1 2 3 4 5 6 7 |
Hello from Hyderabad, Telangana! 🇮🇳 Getting Started with Go — Feb 2026 🚀 |
→ go run = compile in memory + execute immediately. Great for quick tests.
Alternative:
|
0 1 2 3 4 5 6 7 8 9 |
go build # Creates ./hello (executable file) ./hello # Same output |
Step 5: Add an External Package (The Cool Part)
The tutorial uses a famous quote package by Russ Cox (rsc.io/quote).
- Go to https://pkg.go.dev → search “quote” → find rsc.io/quote (v1.5.2 or later in 2026).
- Update hello.go:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
package main import ( "fmt" "rsc.io/quote" ) func main() { fmt.Println(quote.Go()) } |
- Download & lock the dependency:
|
0 1 2 3 4 5 6 |
go mod tidy |
Output something like:
|
0 1 2 3 4 5 6 7 |
go: finding module for package rsc.io/quote go: found rsc.io/quote in rsc.io/quote v1.5.2 |
→ Now you have:
- go.mod updated with require rsc.io/quote v1.5.2
- New file go.sum (checksums for security)
- Run again:
|
0 1 2 3 4 5 6 |
go run . |
Output:
|
0 1 2 3 4 5 6 |
Don't communicate by sharing memory, share memory by communicating. |
→ Classic Go proverb! You just used someone else’s code — zero hassle.
Common Mistakes Beginners Make (I’ll Save You Time)
- Forgot go mod init → go run complains about modules.
- Typed import rsc.io/quote without quotes → syntax error.
- Ran go run hello.go instead of go run . → may miss module context sometimes.
- Old tutorials say GOPATH — ignore them in 2026.
- No internet? go mod tidy fails — need connection first time.
What You’ve Learned So Far (Summary Table)
| Concept | Command / Code | Why It Matters in 2026 |
|---|---|---|
| Installation | Download from go.dev/dl | Gets latest tools |
| Module init | go mod init example.com/name | Enables dependencies |
| Running code | go run . | Fast dev loop |
| Building binary | go build | Creates deployable exe |
| External packages | import “rsc.io/quote” + go mod tidy | Real-world code reuse |
| Package discovery | pkg.go.dev | Find libraries fast |
Next After This Tutorial?
- Finish the official series → https://go.dev/doc/tutorial/create-module (builds a real greetings library + caller app)
- Go back to interactive Tour → https://go.dev/tour (do More Types + Methods)
- Try a tiny project: CLI tool that fetches weather (use external API + net/http)
Ready to open terminal and do this right now? Paste any error you get — we’ll debug live.
Or tell me: want to jump to slices/maps? error handling? a tiny HTTP server next?
You’re killing it — let’s keep the momentum! 💪🇮🇳
