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.