Skip to content

Instantly share code, notes, and snippets.

@narenaryan
Created June 18, 2016 05:48
Show Gist options
  • Select an option

  • Save narenaryan/d5365f1d2c25c4dda7f02504d9abf4c9 to your computer and use it in GitHub Desktop.

Select an option

Save narenaryan/d5365f1d2c25c4dda7f02504d9abf4c9 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
type Point struct{
x int
y int
}
func main() {
p := Point{1,2}
p.y = 23
z := &p
fmt.Println(p)
fmt.Println(z.y)
alterPoint(z)
fmt.Println(p)
alterPoint(&p)
fmt.Println(p)
}
func alterPoint(p *Point) {
p.y = p.y + 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment