[go-nuts] Re: Interface definition as type alias

2020-09-08 Thread Volker Dobler
In practice you never declare the same interface twice switch from one to the other. Why would anybody declare his own ResonseWriter interface if net/http.ResponseWriter exists? So yes: Using a type alias has advantages, but no, this advantage is never realized because neither the alias nor the p

[go-nuts] Re: Interface definition as type alias

2020-09-08 Thread 'Javier Zunzunegui' via golang-nuts
> So yes: Using a type alias has advantages, but no, this advantage is never realized because neither the alias nor the plain type decl are used in practice. The ResonseWriter is a bad example because it has a method `Header() http.Header`, for which you must import net/http regardless. Take f

[go-nuts] Re: Interface definition as type alias

2020-09-08 Thread 'Javier Zunzunegui' via golang-nuts
> The only real downsides, I think, are that compiler errors gets harder to read: > https://github.com/golang/go/issues/21866 > And likewise, that the name won't appear at runtime, so if you print things using `reflect`, the result will be less readable. > ... > https://github.com/golang/go/issue