Files
gibidify/fileproc/writer.go
Ismo Vuorinen b9e2218305 Initial commit
2025-02-07 09:46:31 +02:00

22 lines
566 B
Go

// 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{}{}
}