aboutsummaryrefslogtreecommitdiff
path: root/src/testing/iotest/example_test.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-08-21 14:18:06 -0400
committerCherry Zhang <cherryyz@google.com>2020-08-21 14:18:06 -0400
commit0ef562592fe05b50b0ae8fce495ee7e2eec791f0 (patch)
treed1c0f668e473ebdcb4a30e190008043bdb223bd9 /src/testing/iotest/example_test.go
parentac5c406ef0ab20e2a11f57470271266ef4265221 (diff)
parent9679b307334bce77cc6e50751956a4c717e9458c (diff)
downloadgo-0ef562592fe05b50b0ae8fce495ee7e2eec791f0.tar.xz
[dev.link] all: merge branch 'master' into dev.link
Change-Id: Ic66b5138f3ecd9e9a48d7ab05782297c06e4a5b5
Diffstat (limited to 'src/testing/iotest/example_test.go')
-rw-r--r--src/testing/iotest/example_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/testing/iotest/example_test.go b/src/testing/iotest/example_test.go
new file mode 100644
index 0000000000..10f6bd38f7
--- /dev/null
+++ b/src/testing/iotest/example_test.go
@@ -0,0 +1,22 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package iotest_test
+
+import (
+ "errors"
+ "fmt"
+ "testing/iotest"
+)
+
+func ExampleErrReader() {
+ // A reader that always returns a custom error.
+ r := iotest.ErrReader(errors.New("custom error"))
+ n, err := r.Read(nil)
+ fmt.Printf("n: %d\nerr: %q\n", n, err)
+
+ // Output:
+ // n: 0
+ // err: "custom error"
+}