Created
December 21, 2016 13:00
-
-
Save matiasinsaurralde/abaa66feb8636fe536c106da8019fa37 to your computer and use it in GitHub Desktop.
etc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% go run x.go | |
{0xc420080000} | |
&[{hello}] | |
someFunction receives &[{hello}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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