type noRows struct{}
var _ Result = noRows{}
My question is why initialize a variable but discard it immediately?
type noRows struct{}
var _ Result = noRows{}
My question is why initialize a variable but discard it immediately?
Some people use a line like as an interface check. This line ensures that the type noRows
implements the Result
interface. If it doesn't you will get a compiler error.
I believe checks like that are unnecessary. Normally any type of test involving that type will tell you when a type does not satisfy and important interface. In very rare cases, you can add a conversion test to your unit tests.