Documentation ¶
Overview ¶
Copyright 2022 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- func Discard(n int, err error)
- func DiscardLen(n int, err error) error
- func FprintfDiscard(w io.Writer, format string, a ...any)
- func FprintfErr(w io.Writer, format string, a ...any) error
- func InvokeToString(fn func(writer DiscardStringWriter)) string
- func SafeReadData(r io.Reader, n uint64, chunkSize uint64) ([]byte, error)
- func SafeReadDataAt(r io.ReaderAt, n uint64, off int64, chunkSize uint64) ([]byte, error)
- func SafeSliceCap(v any, c uint64, chunkSize uint64) int
- func WriteAdd(w io.Writer, p []byte, n *int) error
- func WriteByte(w io.Writer, b byte) (int, error)
- func WriteByteDiscard(w io.Writer, b byte)
- func WriteByteErr(w io.Writer, b byte) error
- func WriteDiscard(w io.Writer, p []byte)
- func WriteErr(w io.Writer, p []byte) error
- func WriteString(w io.Writer, s string) (int, error)
- func WriteStringAdd(w io.StringWriter, s string, n *int) error
- func WriteStringDiscard(w io.Writer, s string)
- func WriteStringErr(w io.Writer, s string) error
- type DiscardStringWriter
- type DiscardingWriter
- type IndentWriter
- type OffsetReaderAt
- type PooledBufioWriter
- type ReaderAtReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiscardLen ¶
func InvokeToString ¶
func InvokeToString(fn func(writer DiscardStringWriter)) string
func SafeReadData ¶
ReadData reads n bytes from the input stream, but avoids allocating all n bytes if n is large. This avoids crashing the program by allocating all n bytes in cases where n is incorrect.
The error is io.EOF only if no bytes were read. If an io.EOF happens after reading some but not all the bytes, ReadData returns io.ErrUnexpectedEOF.
func SafeReadDataAt ¶
ReadDataAt reads n bytes from the input stream at off, but avoids allocating all n bytes if n is large. This avoids crashing the program by allocating all n bytes in cases where n is incorrect.
func SafeSliceCap ¶
SliceCap returns the capacity to use when allocating a slice. After the slice is allocated with the capacity, it should be built using append. This will avoid allocating too much memory if the capacity is large and incorrect.
A negative result means that the value is always too big.
The element type is described by passing a pointer to a value of that type. This would ideally use generics, but this code is built with the bootstrap compiler which need not support generics. We use a pointer so that we can handle slices of interface type.
func WriteByteDiscard ¶
func WriteDiscard ¶
func WriteStringAdd ¶
func WriteStringAdd(w io.StringWriter, s string, n *int) error
func WriteStringDiscard ¶
Types ¶
type DiscardStringWriter ¶
type DiscardStringWriter interface {
WriteString(string)
}
func NewDiscardStringWriter ¶
func NewDiscardStringWriter(w io.StringWriter) DiscardStringWriter
type DiscardingWriter ¶
func Dw ¶
func Dw(w io.Writer) DiscardingWriter
func (DiscardingWriter) Byte ¶
func (d DiscardingWriter) Byte(b byte) DiscardingWriter
func (DiscardingWriter) Bytes ¶
func (d DiscardingWriter) Bytes(p []byte) DiscardingWriter
func (DiscardingWriter) Fprintf ¶
func (d DiscardingWriter) Fprintf(format string, a ...any) DiscardingWriter
func (DiscardingWriter) String ¶
func (d DiscardingWriter) String(s string) DiscardingWriter
type IndentWriter ¶
type IndentWriter struct {
// contains filtered or unexported fields
}
func NewIndentWriter ¶
func NewIndentWriter(w DiscardStringWriter, indent string) *IndentWriter
func (*IndentWriter) Dedent ¶
func (w *IndentWriter) Dedent()
func (*IndentWriter) Indent ¶
func (w *IndentWriter) Indent()
func (*IndentWriter) WriteString ¶
func (w *IndentWriter) WriteString(s string)
type OffsetReaderAt ¶
type PooledBufioWriter ¶
type PooledBufioWriter struct {
// contains filtered or unexported fields
}
func NewPooledBufioWriter ¶
func (*PooledBufioWriter) Flush ¶
func (pw *PooledBufioWriter) Flush() error
func (*PooledBufioWriter) Get ¶
func (pw *PooledBufioWriter) Get() *bufio.Writer
func (*PooledBufioWriter) Pooled ¶
func (pw *PooledBufioWriter) Pooled() *bufio.Writer