Documentation ¶
Index ¶
- Constants
- func EqualError(actual error, expected error, a ...any) (bool, string)
- func EqualErrorf(actual error, expected error, format string, a ...any) (bool, string)
- func Error(v any, a ...any) (bool, string)
- func Errorf(v any, format string, a ...any) (bool, string)
- func Nil(v any, a ...any) (bool, string)
- func Nilf(v any, format string, a ...any) (bool, string)
- func NonError(v any, a ...any) (bool, string)
- func NonErrorf(v any, format string, a ...any) (bool, string)
- func NonNil(v any, a ...any) (bool, string)
- func NonNilf(v any, format string, a ...any) (bool, string)
- func NonZero(v any, a ...any) (bool, string)
- func NonZerof(v any, format string, a ...any) (bool, string)
- func Zero(v any, a ...any) (bool, string)
- func Zerof(v any, format string, a ...any) (bool, string)
- type Channel
- func (c *Channel) Clear(ctx context.Context) error
- func (c *Channel) Receive(ctx context.Context) (any, error)
- func (c *Channel) ReceiveOrFail() (any, bool)
- func (c *Channel) Replace(value any)
- func (c *Channel) Send(value any)
- func (c *Channel) SendContext(ctx context.Context, value any) error
- func (c *Channel) SendOrFail(value any) bool
Constants ¶
const DefaultChanBufferSize = 1
DefaultChanBufferSize is the default buffer size of the underlying channel.
Variables ¶
This section is empty.
Functions ¶
func EqualError ¶
EqualError asserts that a function returned an error (i.e. not `nil`) and that it is equal to the provided error.
func EqualErrorf ¶
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
Channel wraps a generic channel and provides a timed receive operation.
func NewChannelWithSize ¶
NewChannelWithSize returns a new Channel with a buffer of bufSize.
func (*Channel) Clear ¶
Clear drains all values on the underlying channel, or the error returned by ctx if it is closed or cancelled.
func (*Channel) Receive ¶
Receive returns the value received on the underlying channel, or the error returned by ctx if it is closed or cancelled.
func (*Channel) ReceiveOrFail ¶
ReceiveOrFail returns the value on the underlying channel and true, or nil and false if the channel was empty.
func (*Channel) Replace ¶
Replace clears the value on the underlying channel, and sends the new value.
It's expected to be used with a size-1 channel, to only keep the most up-to-date item. This method is inherently racy when invoked concurrently from multiple goroutines.
func (*Channel) SendContext ¶
SendContext sends value on the underlying channel, or returns an error if the context expires.
func (*Channel) SendOrFail ¶
SendOrFail attempts to send value on the underlying channel. Returns true if successful or false if the channel was full.