bio

package standard library
go1.17.11 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package bio implements common I/O abstractions used within the Go toolchain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustClose

func MustClose(c io.Closer)

MustClose closes Closer c and calls log.Fatal if it returns a non-nil error.

func MustWriter

func MustWriter(w io.Writer) io.Writer

MustWriter returns a Writer that wraps the provided Writer, except that it calls log.Fatal instead of returning a non-nil error.

Types

type Reader

type Reader struct {
	*bufio.Reader
	// contains filtered or unexported fields
}

Reader implements a seekable buffered io.Reader.

func NewReader added in go1.16

func NewReader(f *os.File) *Reader

NewReader returns a Reader from an open file.

func Open

func Open(name string) (*Reader, error)

Open returns a Reader for the file named name.

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) File added in go1.11

func (r *Reader) File() *os.File

func (*Reader) MustSeek added in go1.13

func (r *Reader) MustSeek(offset int64, whence int) int64

func (*Reader) Offset

func (r *Reader) Offset() int64

func (*Reader) Slice added in go1.13

func (r *Reader) Slice(length uint64) ([]byte, bool, error)

Slice reads the next length bytes of r into a slice.

This slice may be backed by mmap'ed memory. Currently, this memory will never be unmapped. The second result reports whether the backing memory is read-only.

func (*Reader) SliceRO added in go1.13

func (r *Reader) SliceRO(length uint64) []byte

SliceRO returns a slice containing the next length bytes of r backed by a read-only mmap'd data. If the mmap cannot be established (limit exceeded, region too small, etc) a nil slice will be returned. If mmap succeeds, it will never be unmapped.

type Writer

type Writer struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

Writer implements a seekable buffered io.Writer.

func Create

func Create(name string) (*Writer, error)

Create creates the file named name and returns a Writer for that file.

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) File added in go1.11

func (w *Writer) File() *os.File

func (*Writer) MustSeek added in go1.13

func (w *Writer) MustSeek(offset int64, whence int) int64

func (*Writer) Offset

func (w *Writer) Offset() int64

Jump to

Keyboard shortcuts

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