diff options
Diffstat (limited to 'libgo/go/io/example_test.go')
-rw-r--r-- | libgo/go/io/example_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libgo/go/io/example_test.go b/libgo/go/io/example_test.go index bf16de8fe23..af478537267 100644 --- a/libgo/go/io/example_test.go +++ b/libgo/go/io/example_test.go @@ -204,6 +204,28 @@ func ExampleSectionReader_Seek() { // stream } +func ExampleSeeker_Seek() { + r := strings.NewReader("some io.Reader stream to be read\n") + if _, err := io.Copy(os.Stdout, r); err != nil { + log.Fatal(err) + } + + r.Seek(15, io.SeekStart) + if _, err := io.Copy(os.Stdout, r); err != nil { + log.Fatal(err) + } + + r.Seek(-5, io.SeekEnd) + if _, err := io.Copy(os.Stdout, r); err != nil { + log.Fatal(err) + } + + // Output: + // some io.Reader stream to be read + // stream to be read + // read +} + func ExampleMultiWriter() { r := strings.NewReader("some io.Reader stream to be read\n") |