This is how you can do it in go
:
e.Data = make(map[string]string)
e.Data["filla_a"] = "THE_FILLA_A"
temp := make(map[string]interface{})
temp["po_id"] = event.Data["id"]
func B(temp map[string]interface{}, event *Event) map[string]interface{}{
temp["filla_a"] = event.Data["filla_a"]
I have assumed/made event
as struct
and declared the same in the program.
The map
in go
is a reference type (or better say it has pointer reference to internal data structures), so you do not need to pass a pointer
of map
, just pass/return the variable itself.
On the other hand struct
(the Type of e
in the main()
function) is value
type and need to be passed as a pointer to persist updates from called function.
NOTE: the new
keyword creates a pointer to the type. Thus the variable e
in the main()
function is actually a pointer to the Type Event
.
Go Playground: https://play.golang.org/p/Jbkm6z5a2Az
Hope it helps.