// Race yields the result of the 'winner', all other functions are canceled.
Race yields the result of the 'winner', all other functions are canceled.
// Race yields the result of the ' winner ' all other functions are canceled .
func ExampleRace() {
	var (
		f1 = func(ctx context.Context) error {
			fmt.Println("Won the race!")
			return nil
		}
		f2 = func(ctx context.Context) error {
			select {
			case <-ctx.Done():
				return nil
			}
		}
	)
	if err := Race(context.Background(), f1, f2); err != nil {
		log.Fatalf("Error occurred: %v", err)
	}
}
func ExampleRace ( ) { var ( f1 = func ( ctx context . Context ) error { fmt . Println ( " " ) return nil } f2 = func ( ctx context . Context ) error { select { case <- ctx . Done ( ) : return nil } } ) if err := Race ( context . Background ( ) , f1 , f2 ) ; err != nil { log . Fatalf ( " " , err ) } }
Race yields the result of the 'winner', all other functions are canceled.
Race yields the result of the ' winner ' all other functions are canceled .
// Output: Won the race!