You’ve got types and variables from the previous article. Today: Go control structures. The news: Go has fewer pieces than any language you’ve used. The surprise: you won’t miss a single one. if: no parentheses, one trick Go’s if drops the parentheses and demands braces always, whether it’s one line or twenty (A Tour of […]
READ MORE
Go functions look like any language’s functions until they return two things at once and nothing weird happens. Today: syntax, multiple returns, variadics, closures and defer, your open resources’ best friend. Syntax: the type goes after The type after the name feels odd for ten minutes, then reads better, especially in complex signatures. The official […]
READ MORE
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