diff --git a/of.go b/of.go index f3a259e..d14e687 100644 --- a/of.go +++ b/of.go @@ -20,13 +20,13 @@ func OfDelayedFunc[T any](delayFunc func(value T) time.Duration, values ...T) <- out := make(chan T, len(values)) go func(out chan T, values []T) { + defer close(out) for i, value := range values { out <- value if i < len(values)-1 { time.Sleep(delayFunc(value)) } } - close(out) }(out, values) return out