etcd: Index | Files

package ioutil

import ""

Package ioutil implements I/O utility functions.


Package Files

pagewriter.go readcloser.go reader.go util.go


var (
    ErrShortRead = fmt.Errorf("ioutil: short read")
    ErrExpectEOF = fmt.Errorf("ioutil: expect EOF")

func NewExactReadCloser Uses

func NewExactReadCloser(rc io.ReadCloser, totalBytes int64) io.ReadCloser

NewExactReadCloser returns a ReadCloser that returns errors if the underlying reader does not read back exactly the requested number of bytes.

func NewLimitedBufferReader Uses

func NewLimitedBufferReader(r io.Reader, n int) io.Reader

NewLimitedBufferReader returns a reader that reads from the given reader but limits the amount of data returned to at most n bytes.

func WriteAndSyncFile Uses

func WriteAndSyncFile(filename string, data []byte, perm os.FileMode) error

WriteAndSyncFile behaves just like ioutil.WriteFile in the standard library, but calls Sync before closing the file. WriteAndSyncFile guarantees the data is synced if there is no error returned.

type PageWriter Uses

type PageWriter struct {
    // contains filtered or unexported fields

PageWriter implements the io.Writer interface so that writes will either be in page chunks or from flushing.

func NewPageWriter Uses

func NewPageWriter(w io.Writer, pageBytes, pageOffset int) *PageWriter

NewPageWriter creates a new PageWriter. pageBytes is the number of bytes to write per page. pageOffset is the starting offset of io.Writer.

func (*PageWriter) Flush Uses

func (pw *PageWriter) Flush() error

Flush flushes buffered data.

func (*PageWriter) FlushN Uses

func (pw *PageWriter) FlushN() (int, error)

FlushN flushes buffered data and returns the number of written bytes.

func (*PageWriter) Write Uses

func (pw *PageWriter) Write(p []byte) (n int, err error)

type ReaderAndCloser Uses

type ReaderAndCloser struct {

ReaderAndCloser implements io.ReadCloser interface by combining reader and closer together.

Package ioutil imports 4 packages (graph) and is imported by 750 packages. Updated 2020-04-29. Refresh now. Tools for package owners.