Thanks to generics, there are some interesting new ways to program in Go. This article explains how we can use functional programming techniques like Map, Filter, and Reduce, and what kind of problems they might help us to solve.
All tagged Golang
Thanks to generics, there are some interesting new ways to program in Go. This article explains how we can use functional programming techniques like Map, Filter, and Reduce, and what kind of problems they might help us to solve.
Tests communicate a lot of information, to readers, other developers, and even our future selves. Well-written tests focus on a single unit of behaviour that can be described in a brief sentence, and we can use that sentence as the name of the test.
Distinguishing between specific error values and types is easy in Go, thanks to the (relatively) new errors.Is and errors.As functions. Let’s talk about what they do, when and how to use them, and how to know which one is appropriate.
Usually what matters about an error is that it’s not nil, but what if we want to know whether it’s some specific error value? For example, in a test? Let’s look at some of the right and wrong ways to do that.
How should we test errors in Go? And how does the need for this testing influence the way we construct, handle, and pass around errors within our Golang programs?
Alex Edwards’s new book Let’s Go Further is both an essential reference for Go developers and a valuable compendium of battle-tested knowledge about using Go in practice. Read my review to learn more.
Pointers in Go sound scary, but they’re actually very straightforward. Let’s find out what they are, why we need them, and what to watch out for.
I spend a lot of time working with students to help them write clearer, better, and more useful Go programs, using a fairly small set of general principles, and here they are. The first is “be boring”, and I’ve tried to follow that advice.