WriteIntoWriter handles error values
This commit is contained in:
parent
e9fdfd6e42
commit
9e62bab91e
@ -23,6 +23,10 @@ func WriteIntoDelayed[T any](ch chan<- T, delay time.Duration, values ...T) {
|
|||||||
func WriteIntoWriter[T any](ch <-chan T, writers ...io.Writer) {
|
func WriteIntoWriter[T any](ch <-chan T, writers ...io.Writer) {
|
||||||
w := io.MultiWriter(writers...)
|
w := io.MultiWriter(writers...)
|
||||||
EachSuccessive(ch, func(value T) {
|
EachSuccessive(ch, func(value T) {
|
||||||
|
if err, ok := any(value).(error); ok {
|
||||||
|
fmt.Fprintln(w, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Fprintln(w, value)
|
fmt.Fprintln(w, value)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user