if got zero value or invalid or nil, not pass through
This commit is contained in:
parent
4d19b8a8df
commit
08b96819ef
9
main.go
9
main.go
|
@ -1,6 +1,9 @@
|
||||||
package gostream
|
package gostream
|
||||||
|
|
||||||
import "errors"
|
import (
|
||||||
|
"errors"
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
type StreamOption struct {
|
type StreamOption struct {
|
||||||
WaterMark int // buffer len
|
WaterMark int // buffer len
|
||||||
|
@ -124,8 +127,12 @@ func (tr *TransformStream[T, K]) OnData(cb func(K)) error {
|
||||||
go func() {
|
go func() {
|
||||||
for k := range tr.writer {
|
for k := range tr.writer {
|
||||||
transfered := tr.ITransformer.Transform(k)
|
transfered := tr.ITransformer.Transform(k)
|
||||||
|
tvalue := reflect.ValueOf(transfered)
|
||||||
|
if !tvalue.IsZero() && !tvalue.IsValid() {
|
||||||
tr.reader <- transfered
|
tr.reader <- transfered
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue