goprocess.go
func Go(f ProcessFunc) Process {
	// return GoChild(Background(), f)

	// we use two processes, one for communication, and
	// one for ensuring we wait on the function (unclosable from the outside).
	p := newProcess(nil)
	waitFor := newProcess(nil)
	p.WaitFor(waitFor) // prevent p from closing
	go func() {
		f(p)
		waitFor.Close() // allow p to close.
		p.Close()       // ensure p closes.
	}()
	return p
}
func Go(f ProcessFunc) Process {
	// return GoChild(Background(), f)

	// we use two processes, one for communication, and
	// one for ensuring we wait on the function (unclosable from the outside).
	p := newProcess(nil)
	waitFor := newProcess(nil)
	p.WaitFor(waitFor) // prevent p from closing
	go func() {
		f(p)
		waitFor.Close() // allow p to close.
		p.Close()       // ensure p closes.
	}()
	return p
}
func Go ( f ProcessFunc ) Process { // return GoChild(Background(), f) // we use two processes, one for communication, and // one for ensuring we wait on the function (unclosable from the outside). p := newProcess ( nil ) waitFor := newProcess ( nil ) p . WaitFor ( waitFor ) // prevent p from closing go func ( ) { f ( p ) waitFor . Close ( ) // allow p to close. p . Close ( ) // ensure p closes. } ( ) return p }
// Go is much like `go`: it runs a function in a newly spawned goroutine. The neat
// part of Go is that it provides Process object to communicate between the
// function and the outside world. Thus, callers can easily WaitFor, or Close the
// function. It is the function's responsibility to respect the Closing of its Process,
// namely it should exit (return) when <-Closing() is ready. It is simply:
//
//   func Go(f ProcessFunc) Process {
//     p := WithParent(Background())
//     p.Go(f)
//     return p
//   }
//
// Note that a naive implementation of Go like the following would not work:
//
//   func Go(f ProcessFunc) Process {
//     return Background().Go(f)
//   }
//
// This is because having the process you
Go is much like go : it runs a function in a newly spawned goroutine . The neat part of Go is that it provides Process object to communicate between the function and the outside world . Thus callers can easily WaitFor or Close the function . It is the function s responsibility to respect the Closing of its Process namely it should exit ( return ) when < - Closing () is ready . It is simply : func Go ( f ProcessFunc ) Process { p : = WithParent ( Background () ) p . Go ( f ) return p } Note that a naive implementation of Go like the following would not work : func Go ( f ProcessFunc ) Process { return Background () . Go ( f ) } This is because having the process you