func BenchmarkWalkN(b *testing.B) {
	var list error
	for i := 1; i <= listLen; i++ {
		list = errors.Append(list, fmt.Errorf("number %v", i))
	}
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		errors.WalkN(list, attentionSpan, func(e error) {
			_ = e
		})
	}
}
Beispiel #2
0
func ExampleWalkN() {
	var list error
	for i := 1; i <= 1000; i++ {
		list = errors.Append(list, fmt.Errorf("number %v", i))
	}
	errors.WalkN(list, 3, func(e error) {
		// In real code, this should generally use os.Stderr, but
		// https://code.google.com/p/go/issues/detail?id=4550
		// broke that for examples.
		fmt.Fprintln(os.Stdout, e)
	})
	// Output:
	// number 1
	// number 2
	// number 3
}