codekingpro/portable-devtools
114k
1// Copyright 2020 The Go Authors. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.4 5package iotest_test6 7import (8 "errors"9 "fmt"10 "testing/iotest"11)12 13func ExampleErrReader() {14 // A reader that always returns a custom error.15 r := iotest.ErrReader(errors.New("custom error"))16 n, err := r.Read(nil)17 fmt.Printf("n: %d\nerr: %q\n", n, err)18 19 // Output:20 // n: 021 // err: "custom error"22}23 