Skip to content

Instantly share code, notes, and snippets.

@kevin-cantwell
Created June 17, 2016 17:22
Show Gist options
  • Save kevin-cantwell/de12ec90888300c332c4ea2727147b9f to your computer and use it in GitHub Desktop.
Save kevin-cantwell/de12ec90888300c332c4ea2727147b9f to your computer and use it in GitHub Desktop.
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