ioutil

package
v4.0.0-rc8+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyReader = errors.New("reader is empty")
)

Functions

func CheckClose

func CheckClose(c io.Closer, err *error)

CheckClose is used with defer to close the given io.Closer and check its returned error value. If Close returns an error and the given *error is not nil, *error is set to the error returned by Close.

CheckClose is typically used with named return values like so:

func do(obj *Object) (err error) {
  w, err := obj.Writer()
  if err != nil {
    return nil
  }
  defer CheckClose(w, &err)
  // work with w
}

func NewReadCloser

func NewReadCloser(r io.Reader, c io.Closer) io.ReadCloser

NewReadCloser creates an `io.ReadCloser` with the given `io.Reader` and `io.Closer`.

func NonEmptyReader

func NonEmptyReader(r io.Reader) (io.Reader, error)

NonEmptyReader takes a reader and returns it if it is not empty, or `ErrEmptyReader` if it is empty. If there is an error when reading the first byte of the given reader, it will be propagated.

func WriteNopCloser

func WriteNopCloser(w io.Writer) io.WriteCloser

WriteNopCloser returns a WriteCloser with a no-op Close method wrapping the provided Writer w.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL