f96cc9c955
* HTTPRanger * Migrate eestream library to use ReadCloser instead of Reader * Use MultiReadCloser instead of MultiReader * Adapt example cli cmds to latest serverbox changes * Close LazyReadCloser only if only generated * Close ReadClosers sequentially * Close response body on unexpected status code * Avoid double close of the pipe reader * Better formatting for imports * Exit instead of panicking
24 lines
449 B
Go
24 lines
449 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package readcloser
|
|
|
|
import "io"
|
|
|
|
// FatalReadCloser returns a ReadCloser that always fails with err.
|
|
func FatalReadCloser(err error) io.ReadCloser {
|
|
return &fatalReadCloser{Err: err}
|
|
}
|
|
|
|
type fatalReadCloser struct {
|
|
Err error
|
|
}
|
|
|
|
func (f *fatalReadCloser) Read(p []byte) (n int, err error) {
|
|
return 0, f.Err
|
|
}
|
|
|
|
func (f *fatalReadCloser) Close() error {
|
|
return nil
|
|
}
|