github.com/wfusion/gofusion@v1.1.14/common/infra/watermill/pkg/channel.go (about) 1 package pkg 2 3 // IsChannelClosed returns true if provided `chan struct{}` is closed. 4 // IsChannelClosed panics if message is sent to this channel. 5 func IsChannelClosed(channel chan struct{}) bool { 6 select { 7 case _, ok := <-channel: 8 if ok { 9 panic("received unexpected message") 10 } 11 return true 12 default: 13 return false 14 } 15 }