Checking arguments for nil

In this post, we’ll explore multiple ways to check a Go interface value for nil, and try to expain why you should probably not check them at all. Let’s start with an example to introduce the problem. In Go, when we assign a typed nil value to an interface, the interface will not be equal to nil. Consider the following, We define a Sender interface with two implementations, an EmailSender and SMSSender:...

March 14, 2023