From 1af94520a8ff40ac72f4075ebb5b5b930ecf34aa Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Sun, 30 Jul 2023 13:19:51 -0600 Subject: [PATCH] Added option to wait for signal indefinitely --- signal.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/signal.go b/signal.go index 95adab9..b4efc56 100644 --- a/signal.go +++ b/signal.go @@ -57,7 +57,10 @@ func WaitForReadResult(listener chan *ReadResultSignal, timeout time.Duration, i func WaitForSignal[S Signal](ctx * Context, listener *ListenerExt, timeout time.Duration, signal_type SignalType, check func(S)bool) (S, error) { var zero S - timeout_channel := time.After(timeout) + var timeout_channel <- chan time.Time + if timeout > 0 { + timeout_channel = time.After(timeout) + } for true { select { case signal := <- listener.Chan: