Skip to content

Instantly share code, notes, and snippets.

@benevolent0505
Created October 6, 2012 21:41
Show Gist options
  • Save benevolent0505/3846251 to your computer and use it in GitHub Desktop.
Save benevolent0505/3846251 to your computer and use it in GitHub Desktop.
「A Tour of Go」でGo言語を学ぶ(~#28) ref: http://qiita.com/items/ddaa13be965e15185dad
{1 2} &{1 2} {1 0} {0 0}
package main
import "fmt"
type Vertex struct {
X int
Y int
}
func main() {
v := Vertex{1, 2}
v.X = 4
fmt.Println(v.X)
}
package main
import "fmt"
type Vertex struct {
X, Y int
}
var (
p = Vertex{1, 2} // has type Vertex
q = &Vertex{1, 2} // has type *Vertex
r = Vertex{X: 1} // Y:0 is implicit
s = Vertex{} // X:0 and Y:0
)
func main() {
fmt.Println(p, q, r, s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment