Documentation ¶
Index ¶
- Constants
- func EqualError(actual error, expected error, a ...interface{}) (bool, string)
- func EqualErrorf(actual error, expected error, format string, a ...interface{}) (bool, string)
- func Error(v interface{}, a ...interface{}) (bool, string)
- func Errorf(v interface{}, format string, a ...interface{}) (bool, string)
- func Nil(v interface{}, a ...interface{}) (bool, string)
- func Nilf(v interface{}, format string, a ...interface{}) (bool, string)
- func NonError(v interface{}, a ...interface{}) (bool, string)
- func NonErrorf(v interface{}, format string, a ...interface{}) (bool, string)
- func NonNil(v interface{}, a ...interface{}) (bool, string)
- func NonNilf(v interface{}, format string, a ...interface{}) (bool, string)
- func NonZero(v interface{}, a ...interface{}) (bool, string)
- func NonZerof(v interface{}, format string, a ...interface{}) (bool, string)
- func Zero(v interface{}, a ...interface{}) (bool, string)
- func Zerof(v interface{}, format string, a ...interface{}) (bool, string)
- type Channel
- func (c *Channel) Clear(ctx context.Context) error
- func (c *Channel) Receive(ctx context.Context) (interface{}, error)
- func (c *Channel) ReceiveOrFail() (interface{}, bool)
- func (c *Channel) Replace(value interface{})
- func (c *Channel) Send(value interface{})
- func (c *Channel) SendContext(ctx context.Context, value interface{}) error
- func (c *Channel) SendOrFail(value interface{}) 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 ¶
func (c *Channel) Replace(value interface{})
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) Send ¶
func (c *Channel) Send(value interface{})
Send sends value on the underlying channel.
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.