Richard Wiener - Generic Data Structures and Algorithms in Go: An Applied Approach Using Concurrency, Genericity and Heuristics Published by Apress

In this book listing 1.15 Chess had a deadlock. Here is my updated version of the code.

package main

import (

func main() {
	move := make(chan int)
	quit := make(chan bool)

	go player("Bobby Fischer", move, quit)
	go player("Boris Spassky", move, quit)

	move <- 1

func player(name string, move chan int, quit chan bool) {
	for turn := range move {
		n := rand.Intn(100)
		if n <= 5 && turn >= 5 {
			fmt.Printf("Player %s was check mated and loses\n", name)
		} else {
			fmt.Printf("Player %s has moved.  Turn %d\n", name, turn)
			time.Sleep(500 * time.Millisecond)
			move <- turn
	quit <- true
Men's T-Shirt Champion Light Azure
Halloween Pumpkin Forest Green Tote Bag
Men's Regular Lemon Color T-Shirt XPM2-28 Design
Kids Pullover Hoody Flower Design XPM2-49
Women's Halloween Jack-O-Lantern Pumpkin Face Unisex T-Shirt XPM2-50
Men's Regular T-Shirt Fuchsia XPM2-47
French Terry Men's Zip-Up Hoodie XPM2-27