It is a generally accepted best practice in go to "accept interfaces and
return structs". Just google "golang accept interfaces return structs".
However, there are absolutely times when it is ok, or even necessary, to
return an interface. They key to to read some of the articles about the
practice to understand *why* the advice is given, so you can decide when it
makes sense to go against it.
On Wednesday, October 9, 2019 at 3:39:30 AM UTC-4, Martin Palma wrote:
>
> I'm wondering If it is ok (or good Go code) if an interface method returns
> an other interface? Here an example:
>
> type Querier interface {
> Query() string
> }
>
> type Decoder interface {
> DecodeAndValidate() Querier
> }
>
>
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/f3b6c71e-a400-4a9b-8982-3fb7ceecf350%40googlegroups.com.