mirror of
https://github.com/ivuorinen/gibidify.git
synced 2026-03-12 18:00:24 +00:00
Initial commit
This commit is contained in:
21
fileproc/writer.go
Normal file
21
fileproc/writer.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// Package fileproc provides functions for writing file contents concurrently.
|
||||
package fileproc
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// StartWriter listens on the write channel and writes content to outFile.
|
||||
// When finished, it signals on the done channel.
|
||||
func StartWriter(outFile *os.File, writeCh <-chan WriteRequest, done chan<- struct{}) {
|
||||
writer := io.Writer(outFile)
|
||||
for req := range writeCh {
|
||||
if _, err := writer.Write([]byte(req.Content)); err != nil {
|
||||
logrus.Errorf("Error writing to file: %v", err)
|
||||
}
|
||||
}
|
||||
done <- struct{}{}
|
||||
}
|
||||
Reference in New Issue
Block a user