day string
}
-// Write appends line to the file of day and flushes it to the disk.
+// Write appends line to the file of day with one write to the operating system,
+// without a buffer. A crash of the process then loses nothing.
func (j *journal) Write(day string, line []byte) error {
if day != j.day {
err := j.Close()
return fmt.Errorf("write line: %w", err)
}
- err = j.file.Sync()
- if err != nil {
- return fmt.Errorf("flush line: %w", err)
- }
-
return nil
}