💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
``` //生产者 func productor(out chan <- int) { for i:=0; i<10; i++ { fmt.Println("生产:", i*i) out <- i*i } close(out) } //消费者 func consumer(in <- chan int) { for num:=range in{ fmt.Println("消费者:", num) time.Sleep(time.Second) } } func main() { ch := make(chan int, 5) go productor(ch) consumer(ch) } ```