Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 866 Bytes

File metadata and controls

31 lines (23 loc) · 866 Bytes

Listing E.11: Default case

Code in the file

Tip

Click the links to see the file and its directory in their original locations and state as they were at the time of the listing.

package main

import "fmt"

func isClosed(done chan struct{}) bool {
	select {
	case <-done:
		return true
	default:
		return false
	}
}

func main() {
	done := make(chan struct{})
	fmt.Print("closed:", isClosed(done), ".")
	close(done)
	fmt.Print("closed:", isClosed(done), ".")
}