packagemainimport ("fmt")funcworker(ch chanint, chQuit chanstruct{}) {for {select {case v :=<-ch: fmt.Printf("Got value %d\n", v)case<-chQuit: fmt.Printf("Signalled on quit channel. Finishing\n") chQuit <-struct{}{}return } }}funcmain() { ch, chQuit :=make(chanint), make(chanstruct{})goworker(ch, chQuit) ch <-3 chQuit <-struct{}{}// wait to be signalled back by the worker<-chQuit}-----------Output----------------Got value 3Signalled on quit channel. Finishing