Thanks, actually that's what I was looking for.  Don't have much experience 
using generics (like 2 days) but looks rather inconvinient to do that. This 
pattern is convinient for you and you're using it in your code? You think 
there are plans to introducing some feature which will allow to work with 
*interfaces & generics "normally" (without additional boilerplate?)


czwartek, 21 lipca 2022 o 08:25:44 UTC+2 axel.wa...@googlemail.com 
napisał(a):

> I'm not *entirely* sure what you are asking, but does this help, perchance?
> https://gotipplay.golang.org/p/DmxDIdHrV8o
>
> On Thu, Jul 21, 2022 at 8:10 AM Slawomir Pryczek <slawe...@gmail.com> 
> wrote:
>
>> Actually this is better code for the question
>> https://gotipplay.golang.org/p/GQlB2tyyj53
>>
>> czwartek, 21 lipca 2022 o 08:08:51 UTC+2 Slawomir Pryczek napisał(a):
>>
>>> https://gotipplay.golang.org/p/ojY3RRJRJgy
>>>
>>> func GenericData[T DATA, T1 any]() {
>>> }
>>>
>>> When DATA is interface of pointer type, so methods can modify the 
>>> underlying structure...
>>>
>>> // T1 <- any type, so can instantiate but can't increment as there's no 
>>> interface
>>> var tt T1 
>>> fmt.Println(tt)
>>>
>>> var d T      // T <- DATA interface type, so can't initialize but can 
>>> instantiate
>>> can't instantiate because the object will never initialize (nil)
>>>
>>> Can i create new object of type DATA somehow?
>>>
>>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/4b36ca5e-ab1e-4468-85e5-0467efa34ca9n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/4b36ca5e-ab1e-4468-85e5-0467efa34ca9n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/b95015d2-98d7-4670-b03c-ea321bc98e78n%40googlegroups.com.

Reply via email to