fixed bugs
This commit is contained in:
parent
969bd51948
commit
cc9a4bb6ca
@ -9,14 +9,14 @@ import (
|
|||||||
// WriteInto writes all given values into the channel ch.
|
// WriteInto writes all given values into the channel ch.
|
||||||
// Is is a shorthand for Forward(ch, AsChan(values...))
|
// Is is a shorthand for Forward(ch, AsChan(values...))
|
||||||
func WriteInto[T any](ch chan<- T, values ...T) {
|
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.
|
// WriteIntoDelayed writes all given values into the channel ch.
|
||||||
// It sleeps after every write for the given amount of time.
|
// It sleeps after every write for the given amount of time.
|
||||||
// It is a shorthand for Forward(ch, AsChanDelayed(time, values...))
|
// It is a shorthand for Forward(ch, AsChanDelayed(time, values...))
|
||||||
func WriteIntoDelayed[T any](ch chan<- T, delay time.Duration, values ...T) {
|
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
|
// WriteIntoWriter reads all values from ch and writes them via fmt.Fprintln to all writers
|
||||||
|
7
of.go
7
of.go
@ -1,8 +1,13 @@
|
|||||||
package channel
|
package channel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
// Of returns a channel containing all values
|
// Of returns a channel containing all values
|
||||||
func Of[T any](values ...T) <-chan T {
|
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
|
// OfDelayed behaves like Of but with a pre-defined delay between each value
|
||||||
|
Loading…
Reference in New Issue
Block a user