▲ 5 ▼ My "aha!" moment - Accept interfaces return struct in go
One of the first things I've learned when starting working with Go was that it has so-called proverbs. They are a list of rules, which sound like some smart quotes, which should guide you during your journey. For a long time, I didn't quite understand why I should accept interfaces but return structs. I wanted to return interfaces as well since this would define what my return type does, not what it is exactly. It struck me almost a one full year or working with Go exclusively, how wrong I was. This post explains my line of thought, I hope it might save some of you sometime before you have your Aha! moment.
Register to comment or vote on this story