capture

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: BSD-3-Clause Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package capture provides a bounded, concurrency-safe capture buffer for streamed output such as build or process logs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capture

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

Capture stores written output up to a maximum byte size.

It implements io.Writer so it can be used with io.MultiWriter. Writers may run on multiple goroutines (e.g. a progress display alongside a message stream), so access is guarded. Writes never fail: once the limit is reached the remainder is dropped and the capture is marked truncated.

func New

func New(maxBytes int) *Capture

New returns a Capture that stores at most maxBytes of written output. A non-positive maxBytes captures nothing.

func (*Capture) String

func (c *Capture) String() string

String returns the captured output.

func (*Capture) Truncated

func (c *Capture) Truncated() bool

Truncated reports whether any written output was dropped.

func (*Capture) Write

func (c *Capture) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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