(ctx context.Context, c chan<- T, e interface{})
| 21 | ) |
| 22 | |
| 23 | func 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 | |
| 33 | func zeroValue[T any]() T { |
| 34 | var v T |
no outgoing calls