Go has no classes, no inheritance either, and yet massive systems are written in it. The trick, Go structs for data, methods for behavior, composition for reuse. Step by step. Structs: data, period A struct is a collection of named fields (A Tour of Go, structs): Juicy detail: visibility in Go goes by capitalization. A […]
READ MORE
Go interfaces are the piece that upgrades the language from “cute little language” to “language Kubernetes and Docker are written in”. And they work backwards from what you expect if you come from Java. Implicit implementation: no implements A Go interface is a set of method signatures. Here’s the twist, a type implements it automatically […]
READ MORE
Last article interfaces were pure elegance. Today we visit the basement of Go type assertions: what happens when you need to recover the concrete type living inside an interface, what that ubiquitous any is, and the nil gotcha that has bitten every gopher at least once. The empty interface and any An interface with no […]
READ MORE
Seven articles in and you’ve been using Go slices without knowing what they really are. Today we pop the hood, because the difference between using Go and understanding Go lives exactly here: knowing what’s underneath a []int. Arrays: the foundations you rarely touch Go’s array is fixed size and behaves as a VALUE (A Tour […]
READ MORE