Skip to content

Instantly share code, notes, and snippets.

@matiasinsaurralde
Created December 21, 2016 13:00
Show Gist options
  • Save matiasinsaurralde/abaa66feb8636fe536c106da8019fa37 to your computer and use it in GitHub Desktop.
Save matiasinsaurralde/abaa66feb8636fe536c106da8019fa37 to your computer and use it in GitHub Desktop.
etc
% go run x.go
{0xc420080000}
&[{hello}]
someFunction receives &[{hello}]
package main
import (
"fmt"
)
type RootStruct struct {
Messages *[]Messaging
}
type Messaging struct {
Text string
}
func main() {
rootStruct := RootStruct{}
messages := make([]Messaging, 0)
rootStruct.Messages = &messages
item := Messaging{Text: "hello"}
messages = append(messages, item)
fmt.Println(rootStruct)
fmt.Println(rootStruct.Messages)
someFunction(rootStruct.Messages)
}
func someFunction(arr *[]Messaging) {
fmt.Println("someFunction receives", arr)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment