package main

import (
	"fmt"
	"time"
)

func main() {
	ticker := time.NewTicker(500 * time.Millisecond)
	defer ticker.Stop()

	done := time.After(3 * time.Second)

	for {
		select {
		case <-ticker.C:
			fmt.Println("tick")
		case <-done:
			fmt.Println("done")
			break // MISTAKE: this only breaks out of select, not the for loop!
		}
	}

	// This line is never reached
	fmt.Println("exiting")
}
