Thank you, Ian. It indeed makes documentation easier to read in this case. Unless the interface to be embedded is sufficiently self-documenting, as is the case with `heap.Interface` embedding `sort.Interface`, I will stick to listing the method[s] directly.
https://cs.opensource.google/go/go/+/refs/tags/go1.20.3:src/container/heap/heap.go;l=31-35#:~:text=type-,Interface,-interface%20%7B Thank you Aaron for the earlier reply. Nitin On Friday, April 28, 2023 at 3:13:32 PM UTC-7 Ian Lance Taylor wrote: > On Fri, Apr 28, 2023 at 3:09 PM Nitin Muppalaneni <muppa...@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/1fffc21d-f60a-4845-8cb9-693cd5c6e764n%40googlegroups.com.