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

errbuf

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 4 Imported by: 0

README

errbuf

Simple module for go applications, which allows to collect errors into a buffer.

Documentation

Overview

Package errbuf allows to bufferize errors before processing them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferedError

type BufferedError struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

BufferedError wrapper around errors slice with mutex.

func New added in v1.2.0

func New() *BufferedError

New creates empty BufferedError.

func NewBufferFromError deprecated

func NewBufferFromError(err error) *BufferedError

NewBufferFromError creates new BufferedError from the given error.

Deprecated: use NewFromError instead.

func NewBufferFromWarning deprecated

func NewBufferFromWarning(err error) *BufferedError

NewBufferFromWarning creates new BufferedError and adds given error to warnings.

Deprecated: warnings buffer was removed.

func NewErrorsBuffer deprecated

func NewErrorsBuffer() *BufferedError

NewErrorsBuffer creates empty BufferedError.

Deprecated: use New instead.

func NewFromError added in v1.2.0

func NewFromError(err error) *BufferedError

NewFromError creates new BufferedError from the given error.

func (*BufferedError) Add

func (b *BufferedError) Add(errs ...error)

Add adds given error to the errors buffer. No-op if errors len is 0.

func (*BufferedError) Clear added in v1.2.0

func (b *BufferedError) Clear()

Clear clears internal slice of errors. Freed memory will be collected by GC.

func (*BufferedError) Err

func (b *BufferedError) Err() error

Err returns nil if error buffer is empty or contains only nil errors.

func (*BufferedError) Error

func (b *BufferedError) Error() string

Error formats errors in the buffer into the string.

func (*BufferedError) Format added in v1.2.0

func (b *BufferedError) Format(f fmt.State, verb rune)

func (*BufferedError) Grow added in v1.2.0

func (b *BufferedError) Grow(n int)

Grow grows internal errors slice capacity to hold n number of errors. If actual capacity is bigger than n this function is no-op.

func (*BufferedError) Unwrap

func (b *BufferedError) Unwrap() []error

Unwrap returns a copy of the buffer errors.

Jump to

Keyboard shortcuts

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