Help us shape the future of Go! Take the 2026 Go Developer Survey

truncbuffer

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TruncBuffer

type TruncBuffer struct {
	// contains filtered or unexported fields
}

TruncBuffer is a ring buffer that retains only the last max bytes, discarding older data. This is useful for capturing stderr output in a memory-bounded way when the full output may be arbitrarily large. All methods are safe for concurrent use.

func NewTruncBuffer

func NewTruncBuffer(n int) *TruncBuffer

NewTruncBuffer creates a TruncBuffer that keeps at most n bytes.

func (*TruncBuffer) Bytes

func (t *TruncBuffer) Bytes() []byte

Bytes returns a copy of the current buffer contents in order.

func (*TruncBuffer) String

func (t *TruncBuffer) String() string

String returns the buffer contents as a string.

func (*TruncBuffer) Write

func (t *TruncBuffer) Write(p []byte) (int, error)

Write appends p to the buffer, keeping only the last size bytes. The return value n is the length of p;

Jump to

Keyboard shortcuts

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