Initial commit

This commit is contained in:
Ismo Vuorinen
2025-02-07 09:15:37 +02:00
commit b9e2218305
19 changed files with 873 additions and 0 deletions

21
fileproc/writer.go Normal file
View 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{}{}
}