Early previewThis guide is in development. Items tagged verify are still being checked against official docs.
nebx Learn
GitHub
Menu
Home/Go/Basics
Go

Go

Simple, fast to compile, built for concurrent network services.

Paradigm
Procedural, composition over inheritance
Typing
Static, strong, structural interfaces
Memory
Concurrent low-latency GC
Runs
Single static native binary
Concurrency
Goroutines and channels

Basics

The concepts you need before patterns make sense in Go.

Packages and modules

Code is organised in packages; a go.mod file defines a module and its dependencies. Exported names start with a capital letter.

package main

import "fmt"

func main() {
	fmt.Println("Hello, patterns!")
}

Structs and methods

No classes. Methods attach to named types with a value or pointer receiver.

Implicit interfaces

A type satisfies an interface by having its methods; no implements keyword. This makes small interfaces cheap.

Errors are values

Functions return (result, error). Callers check err != nil explicitly; panic is for unrecoverable bugs.

Goroutines, channels, defer

go f() starts a lightweight goroutine; channels pass data between them; defer schedules cleanup when the function returns.

Saved in this browser only. Part of Clean code foundations (0/5).