~kotrunga/a-tour-of-go

ref: b10fb217bb6c0e0a4214a8d1e71e504481c0a13e a-tour-of-go/basics/structs-slices-maps/1.3.5_struct-literals.go -rw-r--r-- 303 bytes View raw
b10fb217kotrunga Update incorrect comments on 1.3.10 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
	Notes 1.3.5

	- Building structs!
*/

package main

import "fmt"

type Vertex struct {
	X, Y int
}

var (
	v1 = Vertex{1, 2}	// has type Vertex
	v2 = Vertex{X: 1}	// Y:0 is implicit
	v3 = Vertex{}			// X:0 and Y:0
	p = &Vertex{1, 2}	// has type *Vertex
)

func main() {
	fmt.Println(v1, p, v2, v3)
}