mirror of
https://github.com/ivuorinen/gibidify.git
synced 2026-01-26 03:24:05 +00:00
22 lines
566 B
Go
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{}{}
|
|
}
|