async

package
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 0 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunWithProgress

func RunWithProgress[T comparable, R any](
	observer func(T),
	f func(*Progress[T]) (R, error),
) (R, error)

RunWithProgress runs a function with a background goroutine reporting and progress to an observer.

func RunWithProgressE

func RunWithProgressE[T comparable](
	observer func(T),
	f func(*Progress[T]) error,
) error

RunWithProgressE runs a function with a background goroutine reporting and progress to an observer.

Types

type Progress

type Progress[T comparable] struct {
	// contains filtered or unexported fields
}

Progress is a wrapper around a channel which can be used to report progress of an operation. The zero value of Progress is invalid. Use NewProgress to create a new instance.

func NewNoopProgress

func NewNoopProgress[T comparable]() *Progress[T]

NewNoopProgress creates a new instance of Progress that does not report any progress. The progress channel is drained

func NewProgress

func NewProgress[T comparable]() *Progress[T]

NewProgress creates a new instance of Progress.

func (*Progress[T]) Done

func (p *Progress[T]) Done()

Done closes the underlying channel, signaling no more progress will be reported. It is an error to call SetProgress after calling Done.

func (*Progress[T]) Progress

func (p *Progress[T]) Progress() <-chan T

Progress returns the read side of the underlying channel. The channel will be closed when [Done] is called, so a `range` loop may be used to consume all progress updates.

func (*Progress[T]) SetProgress

func (p *Progress[T]) SetProgress(progress T)

SetProgress reports progress to the channel.

Jump to

Keyboard shortcuts

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