OK seems i already got the answer
https://github.com/golang/go/issues/45346#issuecomment-862505803
https://github.com/golang/go/issues/49054

Pada Minggu, 13 Maret 2022 pukul 00.14.22 UTC+7 Richiise Nugraha menulis:

> https://go.dev/play/p/SgTiaeE9J2b?v=gotip
>
> Pada Sabtu, 12 Maret 2022 pukul 23.57.35 UTC+7 Richiise Nugraha menulis:
>
>> Is Go type parameter supports interface union? 
>>
>> My case
>> type MessageSpec interface { MessageA | MessageB }
>> type MessageA interface { ID() uint64 }
>> type MessageB interface { Uid() uint64 }
>>
>> but got compile error:
>> ./prog.go:14:2: cannot use main.MessageA in union (main.MessageA contains 
>> methods) ./prog.go:14:13: cannot use main.MessageB in union (main.MessageB 
>> contains methods)
>>
>> I tried to look for documentation and readed 
>> https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#interface-types-in-union-elements
>>
>> There's example 
>> > type Stringish interface { string | fmt.Stringer }
>>
>> but it also throwing error
>> > ./prog.go:19:11: cannot use fmt.Stringer in union (fmt.Stringer 
>> contains methods)
>>
>> Is this a bug? i know my case is not the same thing as like the one i 
>> referenced from the proposal
>> but it is throwing the same error. 
>> Thanks 
>>
>>

-- 
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/94045799-c215-4d8d-8d47-d13513a7be01n%40googlegroups.com.

Reply via email to