Re: [go-nuts] Re: When do you recommend not using composition?

2023-04-28 Thread Nitin Muppalaneni
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/+/

Re: [go-nuts] Re: When do you recommend not using composition?

2023-04-28 Thread Ian Lance Taylor
On Fri, Apr 28, 2023 at 3:09 PM Nitin Muppalaneni 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 { > ... >

[go-nuts] Re: When do you recommend not using composition?

2023-04-28 Thread Nitin Muppalaneni
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 wri

[go-nuts] Re: When do you recommend not using composition?

2023-04-28 Thread 'Aaron Rubesh' via golang-nuts
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

[go-nuts] When do you recommend not using composition?

2023-04-28 Thread Nitin Muppalaneni
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 recommen

Re: [go-nuts] Help me study resources or guides

2023-04-28 Thread Matt KØDVB
You can find my video class at https://www.youtube.com/playlist?list=PLoILbKo9rG3skRCj37Kn5Zj803hhiuRK6; people seem to like it Matt > On Apr 26, 2023, at 9:45 PM, Nyilynn Htwe wrote: > > I am starting to learn GO programming language with this course >

[go-nuts] Tour of Go in Ukrainian

2023-04-28 Thread Viktor Pakhuchyi
Hi there, I am excited to announce that the GolangUA community has completed the initial version of the 'Tour of Go' translation into Ukrainian. We would be grateful if you could add the link to our translation alongside other language versions. Here is the link: *https://go-tour-ua-translation.l

Re: [go-nuts] fmt.Printf Go-syntax formated representation of the value

2023-04-28 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2023-04-27 at 23:02 -0700, Jérôme LAFORGE wrote: > Hello, > In my unit tests when expected is not the actual result, I like > display actual value with Go-syntax. For example: > if got != expected { > t.Errorf(" %#v", got) // []string{"blah','blah"} > } > > But it want to know if ther