Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cancel ¶
type Cancel func()
Cancel defines close2 cancelation function type.
func Close2 ¶
Close2 idempotently closes provided chan and stores provided value to return as this channel closed value instead of empty value. If provided channel is not a writable channel `NotWritableChannel` error is returned. If provided value doesn't match underlying channel type `ChannelTypeMismatch` error is returned. To cancel the effect of closed value replace call cancel function. Note that provided value won't be automatically collected by GC together with provided channel to remove provided value from the storage call cancel function. Note that after cancelation is called next call to Close2 will cause a panic `close of closed channel`. Note that unless cancelation is called next call to Close2 is safe and won't cause any panic but just update storage value with new provided value. Note that in order to achieve such effect go2close uses `bou.ke/monkey` package to patch all existing channel receive entrypoints, so go2close inherits the same list of restrictions.
type ChannelTypeMismatch ¶
ChannelTypeMismatch defines type mismatch between underlying channel and value kind error type.
func (ChannelTypeMismatch) Error ¶
func (err ChannelTypeMismatch) Error() string
type NotWritableChannel ¶
NotWritableChannel defines not writable channel error type.
func (NotWritableChannel) Error ¶
func (err NotWritableChannel) Error() string