Created
June 17, 2016 17:22
-
-
Save kevin-cantwell/de12ec90888300c332c4ea2727147b9f to your computer and use it in GitHub Desktop.
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 Foo struct { | |
a int32 | |
b int32 | |
c int32 | |
d int32 | |
} | |
var foo = Foo{1, 2, 3, 4} | |
func main() { | |
var ptr *Foo = &foo // Assign foo's address to ptr | |
passByRef(ptr) // Only has to pass foo's address | |
} | |
func passByRef(ptr *Foo) { | |
fmt.Printf("%+v\n", *ptr) // dereference to foo | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment