MCPcopy Index your code
hub / github.com/FunctionStream/function-stream / SendToChannel

Function SendToChannel

common/chan_utils.go:23–31  ·  view source on GitHub ↗
(ctx context.Context, c chan<- T, e interface{})

Source from the content-addressed store, hash-verified

21)
22
23func SendToChannel[T any](ctx context.Context, c chan<- T, e interface{}) bool {
24 select {
25 case c <- e.(T): // It will panic if `e` is not of type `T` or a type that can be converted to `T`.
26 return true
27 case <-ctx.Done():
28 close(c)
29 return false
30 }
31}
32
33func zeroValue[T any]() T {
34 var v T

Callers 3

generateTrafficMethod · 0.92
TestSendToChannelFunction · 0.85
TestReceiveFromChannelFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestSendToChannelFunction · 0.68
TestReceiveFromChannelFunction · 0.68