]> git.giacomolli.uk - onechat/blobdiff - journal.go
Name private helpers for their owning feature
[onechat] / journal.go
index 3fb8f649d7c6cdacfe89d40102f733c3a423433d..745ae790089ec1f5a9bf98debe7e17d212537859 100644 (file)
@@ -77,6 +77,21 @@ func (j *Journal) Write(day string, line []byte) (Position, error) {
        return place, nil
 }
 
        return place, nil
 }
 
+func (j *Journal) closeWriter() error {
+       if j.file == nil {
+               return nil
+       }
+
+       err := j.file.Close()
+       j.file = nil
+       j.day = 0
+       if err != nil {
+               return fmt.Errorf("close day file: %w", err)
+       }
+
+       return nil
+}
+
 // Read returns the line at place without its newline.
 func (j *Journal) Read(place Position) ([]byte, error) {
        reader, open := j.readers[place.day]
 // Read returns the line at place without its newline.
 func (j *Journal) Read(place Position) ([]byte, error) {
        reader, open := j.readers[place.day]
@@ -156,21 +171,6 @@ func (j *Journal) Scan(ctx context.Context, place Position, add func([]byte, Pos
        return nil
 }
 
        return nil
 }
 
-func (j *Journal) closeWriter() error {
-       if j.file == nil {
-               return nil
-       }
-
-       err := j.file.Close()
-       j.file = nil
-       j.day = 0
-       if err != nil {
-               return fmt.Errorf("close day file: %w", err)
-       }
-
-       return nil
-}
-
 // journalDayNumber returns the day YYYY-MM-DD as the number YYYYMMDD.
 func journalDayNumber(day string) (uint32, error) {
        number, err := strconv.ParseUint(strings.ReplaceAll(day, "-", ""), 10, 32)
 // journalDayNumber returns the day YYYY-MM-DD as the number YYYYMMDD.
 func journalDayNumber(day string) (uint32, error) {
        number, err := strconv.ParseUint(strings.ReplaceAll(day, "-", ""), 10, 32)