package syncext import "time" func ReadChannelWithTimeout[T any](c chan T, timeout time.Duration) (T, bool) { afterCh := time.After(timeout) select { case rv := <-c: return rv, true case <-afterCh: return *new(T), false } }