A type-safe streaming library for Go with goroutine-safe sending and receiving.
go get github.com/pixperk/streampackage main
import "github.com/pixperk/stream/stream"
func main() {
s := stream.NewStream[int](10)
go func() {
for i := 0; i < 50; i++ {
s.Send(i)
}
s.Close()
}()
s.Consume(func(i int) error {
// process data
return nil
})
}Creates a new stream with the specified buffer size.
Sends a value to the stream. Returns ErrStreamClosed if the stream is closed.
Returns a receive-only channel for reading values.
Returns a receive-only channel for errors.
Processes all values from the stream using the provided consumer function.
Closes the stream gracefully.
Closes the stream with an error.
MIT