ioutil

package
v0.0.0-...-03dfc37 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package ioutil implements some I/O utility functions which are not covered by the standard library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFile

func AppendFile(dst string, src string) error

AppendFile - appends the file "src" to the file "dst"

func NopCloser

func NopCloser(w io.Writer) io.WriteCloser

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

Types

type LimitWriter

type LimitWriter struct {
	io.Writer
	// contains filtered or unexported fields
}

LimitWriter implements io.WriteCloser.

This is implemented such that we want to restrict an enscapsulated writer upto a certain length and skip a certain number of bytes.

func LimitedWriter

func LimitedWriter(w io.Writer, skipBytes int64, limit int64) *LimitWriter

LimitedWriter takes an io.Writer and returns an ioutil.LimitWriter.

func (*LimitWriter) Close

func (w *LimitWriter) Close() error

Close closes the LimitWriter. It behaves like io.Closer.

func (*LimitWriter) Write

func (w *LimitWriter) Write(p []byte) (n int, err error)

Implements the io.Writer interface limiting upto configured length, also skips the first N bytes.

type WriteOnCloser

type WriteOnCloser struct {
	io.Writer
	// contains filtered or unexported fields
}

WriteOnCloser implements io.WriteCloser and always exectues at least one write operation if it is closed.

This can be useful within the context of HTTP. At least one write operation must happen to send the HTTP headers to the peer.

func WriteOnClose

func WriteOnClose(w io.Writer) *WriteOnCloser

WriteOnClose takes an io.Writer and returns an ioutil.WriteOnCloser.

func (*WriteOnCloser) Close

func (w *WriteOnCloser) Close() error

Close closes the WriteOnCloser. It behaves like io.Closer.

func (*WriteOnCloser) HasWritten

func (w *WriteOnCloser) HasWritten() bool

HasWritten returns true if at least one write operation was performed.

func (*WriteOnCloser) Write

func (w *WriteOnCloser) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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