// A channel that is only closed and received from is a breaker, not an // unfinished pair: close is the broadcast sender. Moxie's spawn model is built // on exactly this - a chan struct{} breaker is closed to wake every listener, // and no value is ever sent. // // The legacy checker counted only ssa.Send as a sender, so a close-only channel // with a receive reported "channel has no sender". Closing a channel with no // send is legal and its listeners wake with the zero value, so the checker now // counts a close of the channel as its sender too. package main import "fmt" func main() { // Termination: a batch program must still be stoppable, so the entry // handles the channel the runtime closes on SIGINT/SIGTERM. select { case <-shutdown: return default: } done := chan struct{}{} close(done) <-done // a closed channel receives immediately fmt.Println("close breaker ok") }