package main
import (
"fmt"
"time"
)
func main() {
go func() {
fmt.Println("1")
}()
go func() {
time.Sleep(100 * time.Millisecond)
fmt.Println("2")
}()
go func() {
time.Sleep(300 * time.Millisecond)
fmt.Println("3")
}()
time.Sleep(500 * time.Millisecond)
}
import (
"fmt"
"time"
)
func main() {
go func() {
fmt.Println("1")
}()
go func() {
time.Sleep(100 * time.Millisecond)
fmt.Println("2")
}()
go func() {
time.Sleep(300 * time.Millisecond)
fmt.Println("3")
}()
time.Sleep(500 * time.Millisecond)
}
2018-02-28
func (p *Person) Move(newAddress string) string { ...}
Person不带*,实参不会 改变
Person不带*,实参不会 改变
2018-02-27
cap :就是在数组长度减去切片位置的起始值的总和得出最终结果。
var num =[6]int{1,2,3,5,6}
var slice1 = num[2:5]
var slice2 = slice1[1:3]
cap(slice2) //6-2-1=3
var num =[6]int{1,2,3,5,6}
var slice1 = num[2:5]
var slice2 = slice1[1:3]
cap(slice2) //6-2-1=3
2018-02-26