-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (52 loc) · 814 Bytes
/
main.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
package main
import (
"fmt"
)
type Stu struct {
name string
age int
gender string
id int
}
func main() {
fmt.Println("go-crud")
stus := make([]Stu, 0, 5)
//Add
fmt.Println("Add")
Create(&stus, Stu{
name: "CAMB",
age: 18,
gender: "Female",
})
Create(&stus, Stu{
name: "Bob",
age: 16,
gender: "Male",
})
fmt.Println(stus)
//Query
fmt.Println("Query `CAMB`")
fmt.Println(
Query(&stus, "CAMB"),
)
//Delete
fmt.Println("Delete `CAMB`")
Delete(&stus, "CAMB")
fmt.Println(stus)
//Update
fmt.Println("Update Bob -> CAMB")
Update(&stus, "Bob", Stu{
name: "CAMB",
age: 114514,
gender: "Female",
})
fmt.Println(stus)
//Add
fmt.Println("Add again")
Create(&stus, Stu{
name: "Bob",
age: 16,
gender: "Male",
})
fmt.Println(stus)
}