Golang News http://golangnews.com Jobs, Code, Videos and News for Go hackers - everything about the go programming language Tue, 04 Jul 2017 15:29:00 +0000 Accept interfaces return structs <p>When writing libraries and packages our goal is for them to be consumed by someone. Either by our own code, but also, hopefully, by others too. We want to make this as simple and frictionless as possible. Accepting interfaces and returning structs can be a powerful way to achieve this. It allows the consumers of our packages to reduce the coupling between their code and yours. It helps clearly define the contract between API and the consumer, it makes it easier when consumers of your code are writing tests for the code that depends on your package.</p> 4 points posted by kenny http://idiomaticgo.com/post/best-practice/accept-interfaces-return-structs 2359 Fri, 30 Jun 2017 12:41:00 +0000