-
Notifications
You must be signed in to change notification settings - Fork 4
/
14_array_of_structs.go
63 lines (58 loc) · 1.28 KB
/
14_array_of_structs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Seriál "Programovací jazyk Go"
// https://www.root.cz/serialy/programovaci-jazyk-go/
//
// Třetí část
// Datové typy v programovacím jazyku Go (2.část)
// https://www.root.cz/clanky/datove-typy-v-programovacim-jazyku-go-2-cast/
//
// Repositář:
// https://github.com/tisnik/go-root/
//
// Seznam demonstračních příkladů ze třetí části:
// https://github.com/tisnik/go-root/blob/master/article_03/README.md
//
// Demonstrační příklad číslo 14:
// Pole struktur.
//
// Dokumentace ve stylu "literate programming":
// https://tisnik.github.io/go-root/article_03/14_array_of_structs.html
package main
import "fmt"
// User je uživatelsky definovaná datová struktura
type User struct {
id uint32
name string
surname string
}
func main() {
var users = [3]User{
User{
id: 1,
name: "Pepek",
surname: "Vyskoč"},
User{
id: 2,
name: "Pepek",
surname: "Vyskoč"},
User{
id: 3,
name: "Josef",
surname: "Vyskočil"},
}
fmt.Println(users)
var users2 = [...]User{
User{
id: 1,
name: "Pepek",
surname: "Vyskoč"},
User{
id: 2,
name: "Pepek",
surname: "Vyskoč"},
User{
id: 3,
name: "Josef",
surname: "Vyskočil"},
}
fmt.Println(users2)
}