| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package parallel | 5 package parallel |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 ) | 9 ) |
| 10 | 10 |
| 11 func ExampleFanOutIn() { | 11 func ExampleFanOutIn() { |
| 12 data := []int{1, 20} | 12 data := []int{1, 20} |
| 13 err := FanOutIn(func(ch chan<- func() error) { | 13 err := FanOutIn(func(ch chan<- func() error) { |
| 14 for _, d := range data { | 14 for _, d := range data { |
| 15 d := d | 15 d := d |
| 16 ch <- func() error { | 16 ch <- func() error { |
| 17 if d > 10 { | 17 if d > 10 { |
| 18 return fmt.Errorf("%d is over 10", d) | 18 return fmt.Errorf("%d is over 10", d) |
| 19 } | 19 } |
| 20 return nil | 20 return nil |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 }) | 23 }) |
| 24 | 24 |
| 25 » fmt.Printf("got: %s", err) | 25 » fmt.Printf("got: %q", err) |
| 26 » // Output: got: ["20 is over 10"] | 26 » // Output: got: "20 is over 10" |
| 27 } | 27 } |
| OLD | NEW |