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

2017-04-11 Thread Th3x0d3r
Not as I expected, but it works,  <https://play.golang.org/p/BcXus3aeM6>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 an interface{} parameter from other interface{} 
> source
>
> Playground : https://play.golang.org/p/utwO2Ru4Eq
>
> Output expected:
>
> Val 1: &{XML}
> Val 2: &{XML}
>
>
> 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.
For more options, visit https://groups.google.com/d/optout.


[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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 <https://play.golang.org/p/fVQrg2C802> and there 
> <https://play.golang.org/p/fVQrg2C802>.
>
> Le mardi 11 avril 2017 15:22:41 UTC+2, Th3x0d3r a écrit :
>>
>> 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 
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[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
>>
>> Playground : https://play.golang.org/p/utwO2Ru4Eq
>>
>> Output expected:
>>
>> Val 1: &{XML}
>> Val 2: &{XML}
>>
>>
>> Thanks 
>>
>
>
> func GetClient(method string, resp interface{}) error {
> result := GetMessage("XML")
> resp = result
> fmt.Printf("Val 1: %v\n", resp)
> return nil
> }
>
> resp is an input parameter, when you pass a value as this parameter into 
> the GetClient function, 
> it is copied into the call in fact.
> Modifications on this copy will not be reflected to the original value 
> outside of the called function.
>
> If you do want to make the modifications visible to caller, you can return 
> it as an output result, or use a pointer parameter instead.
>
>  
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


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

2017-04-11 Thread Th3x0d3r
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 

-- 
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.
For more options, visit https://groups.google.com/d/optout.