package testutil import ( "testing" ) // Go runs fn in a goroutine and waits until fn has completed before // test completion. Done is returned for optionally waiting for fn to // exit. func Go(t *testing.T, fn func()) (done <-chan struct{}) { t.Helper() doneC := make(chan struct{}) t.Cleanup(func() { <-doneC }) go func() { fn() close(doneC) }() return doneC }