Skip to content

Commit

Permalink
feat: move truncate's implementation to core_open
Browse files Browse the repository at this point in the history
  • Loading branch information
ShindouMihou committed Sep 11, 2023
1 parent bb6dea0 commit e378269
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 6 additions & 0 deletions siopao/core_open.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ func (file *File) openWrite(trunc bool) error {
}

file.file = f

if trunc {
if err := file.clear(); err != nil {
return err
}
}
return nil
}

Expand Down
6 changes: 0 additions & 6 deletions siopao/core_read_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,5 @@ func write[T any](file *File, trunc bool, fn func() (*T, error)) (*T, error) {
return nil, err
}
defer file.close()

if trunc {
if err := file.clear(); err != nil {
return nil, err
}
}
return fn()
}

0 comments on commit e378269

Please sign in to comment.