go 语言 无缓冲通道的cap是零

无缓冲通道的cap是零

package main

import (
	"fmt"
	"time"
)

// 无缓冲通道的cap、len永远是0
func main() {
	noCache := make(chan int)

	go func() { noCache <- 6 }()

	time.Sleep(2 * time.Second)
	fmt.Println("cap of noCache pipeline is", cap(noCache)) // => 0
	fmt.Println("len of noCache pipeline is", len(noCache)) // => 0

	fmt.Println("noCache ", <-noCache)
}