package main
import (
"fmt"
)
func main() {
ch := make(chan int)
go func() {
fmt.Println("1")
ch <- 1
}()
<-ch
go func() {
fmt.Println("2")
ch <- 1
}()
<-ch
go func() {
fmt.Println("3")
ch <- 1
}()
<-ch
}
import (
"fmt"
)
func main() {
ch := make(chan int)
go func() {
fmt.Println("1")
ch <- 1
}()
<-ch
go func() {
fmt.Println("2")
ch <- 1
}()
<-ch
go func() {
fmt.Println("3")
ch <- 1
}()
<-ch
}
2019-04-07
func main() {
go fmt.Println("1")
time.Sleep(100*time.Millisecond)
go fmt.Println("2")
time.Sleep(200*time.Millisecond)
go fmt.Println("3")
time.Sleep(300*time.Millisecond)
}
go fmt.Println("1")
time.Sleep(100*time.Millisecond)
go fmt.Println("2")
time.Sleep(200*time.Millisecond)
go fmt.Println("3")
time.Sleep(300*time.Millisecond)
}
2019-04-07
这样不是更简单?
老师的方法也很好,但是感觉饶了路。之前也有遇到过
func main() {
for i := 0; i < 10; i++ {
fmt.Printf("%d ", fibonacci(i))
defer func(n int){
fmt.Printf("%d ", fibonacci(n))
}(i)
}
}
老师的方法也很好,但是感觉饶了路。之前也有遇到过
func main() {
for i := 0; i < 10; i++ {
fmt.Printf("%d ", fibonacci(i))
defer func(n int){
fmt.Printf("%d ", fibonacci(n))
}(i)
}
}
2019-04-06
func read(r io.Reader) ([]byte, error) {
return ioutil.ReadAll(r)
}
return ioutil.ReadAll(r)
}
2019-03-05
func main() {
var wg1 sync.WaitGroup
var wg2 sync.WaitGroup
var wg3 sync.WaitGroup
wg1.Add(1)
wg2.Add(1)
wg3.Add(1)
go func() {
fmt.Println("1")
wg1.Done()
}()
go func() {
wg1.Wait()
fmt.Println("2")
wg2.Done()
}()
go func() {
wg1.Wait()
wg2.Wait()
fmt.Println("3")
wg3.Done()
}()
wg3.Wait()
}
var wg1 sync.WaitGroup
var wg2 sync.WaitGroup
var wg3 sync.WaitGroup
wg1.Add(1)
wg2.Add(1)
wg3.Add(1)
go func() {
fmt.Println("1")
wg1.Done()
}()
go func() {
wg1.Wait()
fmt.Println("2")
wg2.Done()
}()
go func() {
wg1.Wait()
wg2.Wait()
fmt.Println("3")
wg3.Done()
}()
wg3.Wait()
}
2019-03-05
16进制转10进制:
从右往左,位数*16^位数
所以16进制的-1000等于
0*16^0 = 0
0*16^0 = 0
0*16^0 = 0
1*16^3 = 4096
从右往左,位数*16^位数
所以16进制的-1000等于
0*16^0 = 0
0*16^0 = 0
0*16^0 = 0
1*16^3 = 4096
2019-02-18