ioutilx

package
v2.27.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package ioutilx contains additional io utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadN

func ReadN(r io.Reader, n int) ([]byte, error)

ReadN reads exactly N bytes from the reader. Fails otherwise.

func ReadNBufUnsafe

func ReadNBufUnsafe(r io.Reader, b []byte) error

ReadNBufUnsafe reads exactly cap(buf) bytes from the reader. Fails otherwise. Uses the unsafe package unsafely to convince escape analysis that the passed in []byte doesn't escape this function through the io.Reader. Intended for use with small, fixed sized, stack allocated buffers that have no business being allocated to the heap. If the io.Reader somehow retains the passed in []byte, then this should not be used, and ReadN preferred.

func ReadUnsafe

func ReadUnsafe(r io.Reader, b []byte) (int, error)

ReadUnsafe is an unsafe version of read that breaks escape analysis to allow the passed in []byte to be allocated to the stack. Intended for use with small, fixed sized, stack allocated buffers that have no business being allocated to the heap. If the io.Reader somehow retains the passed in []byte, then this should not be used, and ReadN preferred.

func WriteUnsafe

func WriteUnsafe(w io.Writer, b []byte) (int, error)

WriteUnsafe writes the buffer to the given writer, but breaks escape analysis so that the passed in []byte can be allocated to the stack. Use with caution, and only when you're certain the writer doesn't retain the passed in byte buffer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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