1. package main
    2. import (
    3. "fmt"
    4. )
    5. func main() {
    6. var (
    7. chString chan string
    8. chSlice chan []int
    9. )
    10. chSlice = make(chan []int, 1)
    11. chString = make(chan string, 1)
    12. go func() {
    13. chSlice <- make([]int, 1)
    14. chString <- "hello"
    15. close(chSlice)
    16. close(chString)
    17. }()
    18. fmt.Println(<-chSlice, <-chSlice)
    19. fmt.Println(<-chString, <-chString)
    20. }
    1. [0] []
    2. hello