↓ Skip to main content

Learn Golang

16 posts
← All posts
Go: What It Is and Why It's Worth Learning

go

Go: What It Is and Why It's Worth Learning

What Go is, what makes it different from Python and C++, and why so much DevOps tooling is written in it. The first post in a hands-on series that works up to a small web server and a DNS checker.

4 mins
Read the article
Variables, Printing and Comments in Go

go

Variables, Printing and Comments in Go

The four ways to declare a variable in Go, what zero values are, how to print with Println, Printf and Sprintf, and the two kinds of comments.

4 mins
Read the article
Data Types in Go

go

Data Types in Go

The basic types in Go (integers, floats, booleans and strings), how big each one is, what a rune and a byte are, and why 0.1 + 0.2 is not 0.3.

4 mins
Read the article
Escape Sequences in Go

go

Escape Sequences in Go

The escape sequences Go accepts in strings and runes, which ones are only valid in one of the two, and how raw strings let you skip escaping altogether.

3 mins
Read the article
Scope, Type Conversion and Constants in Go

go

Scope, Type Conversion and Constants in Go

Where a variable is visible in Go, the shadowing mistake that catches beginners, why Go has no implicit type conversion, and how typed constants, untyped constants and iota work.

4 mins
Read the article
Operators in Go

go

Operators in Go

Arithmetic, comparison, logical, assignment and bitwise operators in Go, how integer division and the remainder operator behave, and the operators Go deliberately leaves out, such as the ternary.

4 mins
Read the article
Control Flow in Go: if, switch and for

go

Control Flow in Go: if, switch and for

How Go makes decisions and repeats work: if with an init statement, switch without fall-through, the single for loop in its four forms, break and continue, and defer.

3 mins
Read the article
Arrays in Go

go

Arrays in Go

How arrays work in Go: fixed size that is part of the type, zero values, indexing and bounds checks, and why assigning or passing an array copies it.

3 mins
Read the article
Slices in Go

go

Slices in Go

What a slice really is (a pointer, a length and a capacity over an array), how slicing shares memory, how append grows a slice, and the aliasing bug that follows.

4 mins
Read the article
Maps in Go

go

Maps in Go

How Go maps store key-value pairs, why writing to a nil map panics, how to check whether a key exists, why iteration order is random, and what a map can use as a key.

3 mins
Read the article
Functions in Go

go

Functions in Go

Declaring functions in Go, returning several values, the error-return idiom, variadic functions, closures and functions as values, and why Go passes everything by value.

5 mins
Read the article
Pointers in Go

go

Pointers in Go

What a pointer is, how & and * work, why a function needs a pointer to change its caller's variable, what a nil pointer does, and when pointers are worth using.

4 mins
Read the article
Structs, Methods and Interfaces in Go

go

Structs, Methods and Interfaces in Go

Group data with structs, attach behaviour with methods, choose between value and pointer receivers, describe behaviour with interfaces, and reuse code by embedding instead of inheriting.

6 mins
Read the article
Building a Simple Web Server with Go

go

Building a Simple Web Server with Go

Build a small Go web server that serves static files, handles a form and responds to a simple route, using only the standard library's net/http package.

8 mins
Read the article