-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (35 loc) · 981 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
package main
import (
"fmt"
"study.io/go/socket"
)
func swapIntValue(a int, b int) {
fmt.Println("a:", a, " b:", b)
a, b = b, a
fmt.Println("a:", a, " b:", b)
}
func example01() {
var slice = []string{"1", "2"}
fmt.Printf("%p, %v, %v\n", slice, len(slice), cap(slice))
fmt.Printf("%p, %v, %v\n", &slice, len(slice), cap(slice))
slice = append(slice, "3")
fmt.Printf("%p, %v, %v\n", slice, len(slice), cap(slice))
s := add(slice)
fmt.Printf("add(slice) : %p, %v, %v\n", slice, len(slice), cap(slice))
fmt.Printf("s := add(slice) : %p, %v, %v\n", s, len(s), cap(s))
}
func add(slice []string) []string {
fmt.Printf("add start: %p, %v, %v\n", slice, len(slice), cap(slice))
slice = append(slice, "4")
slice[0] = "0"
// slice = append(slice, "5")
// slice = append(slice, "6")
fmt.Printf("add end: %p, %v, %v\n", slice, len(slice), cap(slice))
return slice
}
func main() {
// example01()
// swapIntValue(1, 10)
//example.Studhttp()
socket.StartServer()
}