organizer/bytechan_writer.go

23 lines
327 B
Go
Raw Normal View History

2023-01-15 13:59:48 +01:00
package main
2023-01-15 19:43:36 +01:00
import (
"io"
)
2023-01-15 13:59:48 +01:00
func NewWriterFromByteChan(ch chan byte) *ByteChanWriter {
return &ByteChanWriter{ch}
}
type ByteChanWriter struct {
ch chan byte
}
var _ io.Writer = &ByteChanWriter{}
func (w *ByteChanWriter) Write(p []byte) (n int, err error) {
for _, b := range p {
w.ch <- b
}
return len(p), nil
}