I would recommend reading up on how to implement Go interfaces.

The only requirement required to satisfy the io.Writer interface is a 
method Write([]byte)(int,error). If this method is present, Go can then 
interpret your struct as a io.Writer.

By itself, io.Writer provides no functionality only a definition. That is 
left to the struct to fulfill. 
On Friday, April 28, 2023 at 4:16:24 PM UTC-5 Nitin Muppalaneni wrote:

> Is there a reason why `http.ResponseWriter` does not include io.Writer 
> directly and instead has the `Write([]byte) (int, error)` method? Why did 
> you choose to do it this way? I can see that it adds a dependency on the io 
> package. Was that the concern?
>
> And more generally, when would you recommend not using composition of 
> interfaces?
>
> Thanks
> Nitin
>
>

-- 
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/f8b6844a-72af-460f-a29a-4bb2d9e60a96n%40googlegroups.com.

Reply via email to