[go-nuts] the case for returning interface vs struct

2017-03-01 Thread Tamás Gulácsi
Accept interface (the smallest possible) but return concrete type - possibly a pointer. If you don't want people to mess with your data type directly, unexport (lowercase the first rune in the name) your data type. -- You received this message because you are subscribed to the Google Groups "g

[go-nuts] the case for returning interface vs struct

2017-03-01 Thread Henry
Hi, I am trying to come up with a general guideline about returning struct vs returning interface. I have used both approaches. Despite the common wisdom is to return struct, I believe that returning interface is generally superior to returning struct. Here are my arguments for returning inter