Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Mike Schinkel
> On Mar 13, 2024, at 10:27 AM, Brian Hatfield wrote: > > Client.GetChild() must return GetChilder, not Child. Actually, Client.GetChild() must return b.GetDataer, not b.GetChilder, but the example is a mind bender so it was easy to get wrong. I only got it correct by testing the code and fai

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Jason Phillips
Regardless, that's the reason what you've attempted doesn't work. It has its own entry in the Go FAQ: https://go.dev/doc/faq#covariant_types On Wednesday, March 13, 2024 at 1:00:34 PM UTC-4 Rodrigo Araujo wrote: > 'Cause this dependency makes code more "rigid". A refactor in an isolated > pack

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Rodrigo Araujo
'Cause this dependency makes code more "rigid". A refactor in an isolated package would let to change other packages. Also makes testing more difficult. It is kind of described here: https://go.dev/wiki/CodeReviewComments#interfaces Em qua., 13 de mar. de 2024 às 13:41, burak serdar escreveu: >

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread burak serdar
On Wed, Mar 13, 2024 at 10:31 AM Rodrigo Araujo wrote: > > Do you mean b.GetChilder? In this case, package A will depend on package B > and I don't think this is a good approach. Why would it not be a good approach? You have a package declaring interfaces, and if you have another package using t

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Rodrigo Araujo
Do you mean b.GetChilder? In this case, package A will depend on package B and I don't think this is a good approach. Em qua., 13 de mar. de 2024 às 11:28, Brian Hatfield escreveu: > Client.GetChild() must return GetChilder, not Child. > > On Wed, Mar 13, 2024 at 10:02 AM Rodrigo Araujo wrote:

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Brian Hatfield
Client.GetChild() must return GetChilder, not Child. On Wed, Mar 13, 2024 at 10:02 AM Rodrigo Araujo wrote: > Given the code bellow, I'm trying to keep my packages completely > separated, without knowing each other, but the code doesn't work. I just > can get it running when I define (or use) an

[go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Rodrigo Araujo
Given the code bellow, I'm trying to keep my packages completely separated, without knowing each other, but the code doesn't work. I just can get it running when I define (or use) an interface from one package inside code of the other package. Here is the error: *cannot use client (variable o