Channel Buffering
package main
import "fmt"
func main() {
// Creating a buffered channel named 'messages' with a capacity of 2
messages := make(chan string, 2)
// Sending two messages into the buffered channel
messages <- "buffered"
messages <- "channel"
// Receiving and printing the messages from the buffered channel
fmt.Println(<-messages)
fmt.Println(<-messages)
}Output
buffered
channelLast updated