func main() {
for i := 0; i < 10; i++ {
defer fmt.Printf("%d ", func(i int) int{
fmt.Printf("%d ", fibonacci(i))
return fibonacci(i)
}(i))
}
}
for i := 0; i < 10; i++ {
defer fmt.Printf("%d ", func(i int) int{
fmt.Printf("%d ", fibonacci(i))
return fibonacci(i)
}(i))
}
}
2019-08-29
length := (2)
capacity := (4)
length = (7)
e2 := (0)
e3 := (8)
e4 := (11)
capacity := (4)
length = (7)
e2 := (0)
e3 := (8)
e4 := (11)
2019-08-27
最简单的方法:
package main
import (
"fmt"
"time"
)
func main() {
go func() {
fmt.Println("1")
}()
time.Sleep(100 * time.Millisecond)
go func() {
fmt.Println("2")
}()
time.Sleep(100 * time.Millisecond)
go func() {
fmt.Println("3")
}()
time.Sleep(100 * time.Millisecond)
}
package main
import (
"fmt"
"time"
)
func main() {
go func() {
fmt.Println("1")
}()
time.Sleep(100 * time.Millisecond)
go func() {
fmt.Println("2")
}()
time.Sleep(100 * time.Millisecond)
go func() {
fmt.Println("3")
}()
time.Sleep(100 * time.Millisecond)
}
2019-07-26
package main
import "fmt"
func main() {
ch2 := make(chan string, 1)
go func() {
ch2 <- ("已到达!")
}()
var value string = "数据"
value = value + (<- ch2)
fmt.Println(value)
}
import "fmt"
func main() {
ch2 := make(chan string, 1)
go func() {
ch2 <- ("已到达!")
}()
var value string = "数据"
value = value + (<- ch2)
fmt.Println(value)
}
2019-07-19