hello.go 459 B

12345678910111213141516171819202122232425
  1. package main
  2. import (
  3. "os"
  4. "fmt"
  5. )
  6. func main() {
  7. tab := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }
  8. ch := make(chan bool)
  9. for i := 0; i < 10; i++ {
  10. go func(i int){
  11. fmt.Printf("hello %s fmt.printf %d/%d\n", tab[i], i, len(tab))
  12. ch <- true
  13. }(i);
  14. }
  15. for i := 0; i < 10; i++ {
  16. <-ch
  17. }
  18. os.Stdout.Write([]byte("hello os.write all done\n"))
  19. if _, err := os.Open("/xyz"); err != nil {
  20. fmt.Printf("open failed %v\n", err)
  21. }
  22. }