package main
import (
"fmt"
"time"
"runtime"
)
type Test struct {
name string
}
func (t *Test) pp() {
fmt.Println("point:", t.name)
}
func (t Test) p2() {
fmt.Println("value:", t.name)
}
func tPanic() {
defer fmt.Println("123123123111")
defer fmt.Println("222")
}
var m int
func main() {
tPanic()
var a *int
a = new(int)
fmt.Println(a, *a)
*a = 8
fmt.Println(a, *a)
x, y := uint8(255), uint8(1)
fmt.Printf("uint test: x:%d, y:%d, x+y=%d\n", x, y, x+y)
ss := "hello 出租车"
fmt.Println([]byte(ss),ss[0],ss[7],ss[8])
fmt.Println([]uint8(ss))
fmt.Println([]rune(ss), []rune(ss)[8], string([]rune(ss)[8]))
fmt.Println([]int32(ss))
fmt.Println('a', '的')
fmt.Printf("%t----%t", 'a', '的')
var c chan int
c = make(chan int, 3)
go func(c chan int) {
time.Sleep(time.Second * 1)
close(c)
}(c)
c <- 11
fmt.Println("chan output:", <- c)
fmt.Println("chan output:", <- c)
runtime.GOMAXPROCS(1)
m = 0
for i:=0; i < 1000; i++ {
go add()
}
time.Sleep(time.Second * 1)
fmt.Println(m)
}
func add() {
m++
}