package main
import (
_ "a1/utils"
"fmt"
)
type Cat struct {
Name string
Age int
}
func main() {
var allChan chan interface{}
allChan = make(chan interface{}, 10)
cat1 := Cat{Name: "tom", Age: 18}
cat2 := Cat{Name: "tom~", Age: 180}
allChan <- cat1
allChan <- cat2
// cat11 := <-allChan
// fmt.Println(cat11.(Cat).Age)
close(allChan)
for i := range allChan{
fmt.Println(i)
}
}
go 定义管道、遍历管道
于 2024-01-23 11:47:34 首次发布