[go-nuts] Re: How to set value to empty interface{}

2017-04-11 Thread Th3x0d3r
Not as I expected, but it works, Would it be possible not to use an specific type (*SomeMessage) an instead use interface{} type in assertion? On Tuesday, April 11, 2017 at 9:22:41 AM UTC-4, Th3x0d3r wrote: > > Hey there ! > > How can i set the value of

[go-nuts] Re: How to set value to empty interface{}

2017-04-11 Thread pierre . curto
In Go, everything is passed by value, including interfaces (empty or not). A quick overview at http://goinbigdata.com/golang-pass-by-pointer-vs-pass-by-value/. So, you cannot change the value pointed to by an interface unless you "unbox" it: https://play.golang.org/p/uzccweBdzV Further

[go-nuts] Re: How to set value to empty interface{}

2017-04-11 Thread James Bardin
On Tuesday, April 11, 2017 at 10:10:25 AM UTC-4, Th3x0d3r wrote: > > AFAIK empty interfaces{} are passed by reference > > Nothing in go is "pass by reference". The interface value is always copied. -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Re: How to set value to empty interface{}

2017-04-11 Thread Th3x0d3r
It works this way, but need to use the GetMessage interface value -- 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

[go-nuts] Re: How to set value to empty interface{}

2017-04-11 Thread Th3x0d3r
I would but need to use empty interfaces{} as parameters On Tuesday, April 11, 2017 at 9:52:20 AM UTC-4, Pierre Curto wrote: > > Either pass around the pointer to your struct or use a dedicated interface > to alter the struct contents. > Examples of each here

[go-nuts] Re: How to set value to empty interface{}

2017-04-11 Thread Th3x0d3r
AFAIK empty interfaces{} are passed by reference On Tuesday, April 11, 2017 at 9:46:00 AM UTC-4, T L wrote: > > > > On Tuesday, April 11, 2017 at 9:22:41 PM UTC+8, Th3x0d3r wrote: >> >> Hey there ! >> >> How can i set the value of an interface{} parameter from other >> interface{} source >> >>

[go-nuts] Re: How to set value to empty interface{}

2017-04-11 Thread pierre . curto
Either pass around the pointer to your struct or use a dedicated interface to alter the struct contents. Examples of each here and there . Le mardi 11 avril 2017 15:22:41 UTC+2, Th3x0d3r a écrit : > > Hey there ! > >

[go-nuts] Re: How to set value to empty interface{}

2017-04-11 Thread T L
On Tuesday, April 11, 2017 at 9:22:41 PM UTC+8, Th3x0d3r wrote: > > Hey there ! > > How can i set the value of an interface{} parameter from other interface{} > source > > Playground : https://play.golang.org/p/utwO2Ru4Eq > > Output expected: > > Val 1: &{XML} > Val 2: &{XML} > > > Thanks >