On Fri, Apr 28, 2023 at 3:09 PM Nitin Muppalaneni <muppalan...@gmail.com> wrote:
>
> I understand that interface does not provide the implementation. Perhaps my 
> question was not clear. Let me try with the code snippets.
>
> This is how http.ResponseWriter is written:
> type http.ResponseWriter interface {
>     ...
>     Write([]byte) (int, error)
>     ...
> }
>
> But it could have also been written this way:
> type http.ResponseWriter interface {
>     ...
>     io.Writer
>     ...
> }
>
> The second one uses embedding (https://go.dev/doc/effective_go#embedding), 
> which I thought is preferable. I was curious why embedding was not used here 
> and more broadly, when not to use embedding.

I don't know if this was the actual reason, but personally I think
listing the Write method explicitly makes the documentation easier to
read.

https://pkg.go.dev/net/http#ResponseWriter

Ian

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcV5b75Fpcurb%3D%3Dvypk_uYMJADMtDnx_bgohr%2BPgMeOf9A%40mail.gmail.com.

Reply via email to