From cc9a4bb6ca7d4c743998ab1dccecac47676b0fec Mon Sep 17 00:00:00 2001 From: Tordarus Date: Wed, 9 Feb 2022 12:17:49 +0100 Subject: [PATCH] fixed bugs --- chan_io.go | 4 ++-- of.go | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/chan_io.go b/chan_io.go index 5a382ea..c051655 100644 --- a/chan_io.go +++ b/chan_io.go @@ -9,14 +9,14 @@ import ( // WriteInto writes all given values into the channel ch. // Is is a shorthand for Forward(ch, AsChan(values...)) func WriteInto[T any](ch chan<- T, values ...T) { - Forward(ch, AsChan(values...)) + Forward(ch, Of(values...)) } // WriteIntoDelayed writes all given values into the channel ch. // It sleeps after every write for the given amount of time. // It is a shorthand for Forward(ch, AsChanDelayed(time, values...)) func WriteIntoDelayed[T any](ch chan<- T, delay time.Duration, values ...T) { - Forward(ch, AsChanDelayed(delay, values...)) + Forward(ch, OfDelayed(delay, values...)) } // WriteIntoWriter reads all values from ch and writes them via fmt.Fprintln to all writers diff --git a/of.go b/of.go index 3395250..4ec9492 100644 --- a/of.go +++ b/of.go @@ -1,8 +1,13 @@ package channel +import ( + "context" + "time" +) + // Of returns a channel containing all values func Of[T any](values ...T) <-chan T { - return AsChanDelayed(0, values...) + return OfDelayed(0, values...) } // OfDelayed behaves like Of but with a pre-defined delay between each value