utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: Apache-2.0 Imports: 3 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

This section is empty.

Types

type ErrorGroup

type ErrorGroup struct {
	Errors []error
}

ErrorGroup collates errors

func (*ErrorGroup) Add

func (e *ErrorGroup) Add(err error)

Add adds an error to an existing error group

func (*ErrorGroup) Finalize

func (e *ErrorGroup) Finalize() error

Finalize returns an error corresponding to the ErrorGroup state. If there's no errors in the group, finalize returns nil. If there's only one error, Finalize returns that error. Otherwise, Finalize will make a new error consisting of the messages from the constituent errors.

type Future

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

Future is a type that is essentially the inverse of a channel. With a channel, you have multiple senders and one receiver. With a future, you can have multiple receivers and one sender. Additionally, a future protects against double-sends. Since this is usually used for returning function results, we also capture and return error values as well. Use NewFuture to initialize.

func NewFuture

func NewFuture() *Future

NewFuture returns an initialized and ready Future.

func (*Future) Fired

func (self *Future) Fired() bool

Fired returns whether or not a value has been set. If Fired is true, Get won't block.

func (*Future) Get

func (self *Future) Get() (interface{}, error)

Get blocks until the Future has a value set.

func (*Future) Set

func (self *Future) Set(val interface{}, err error)

Set provides the value to present and future Get calls. If Set has already been called, this is a no-op.

Jump to

Keyboard shortcuts

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