package lib // Worker is a spawn target. Its sole result is named `closed`, and that name // together with the type is the contract: the runtime binds the domain's // breaker into the result, and the target selects on it to learn that its // parent ended the domain. func Worker(in chan []byte, out chan []byte) (closed chan struct{}) { for { select { case <-closed: return closed case msg := <-in: out <- msg } } } // Plain has the shape of a spawn target but its result is not named `closed`, // so it is an ordinary function and may be called directly. Before the name // became part of the contract, the shape alone classified it as a target and // the direct call died in its prologue with "spawn target called directly". func Plain(in chan []byte) (out chan []byte) { out = in in <- []byte("plain") return }