Skip to content

v0.1.0 — Initial Release

Choose a tag to compare

@LarsArtmann LarsArtmann released this 11 Jul 20:18
· 260 commits to master since this release

TOCTOU-safe file writes for Go

Initial release providing race-free file writes via xxhash64 fingerprint verification, cross-platform file locking, and atomic rename.

Added

  • TOCTOU-safe file writes via xxhash64 fingerprint verification
  • Cross-platform file locking (flock on Unix, LockFileEx on Windows) via gofrs/flock
  • Atomic rename with .bak backup of previous content
  • Fingerprint type ([8]byte) with IsZero() and Matches() methods
  • FingerprintFile — computes fingerprint from file path (zero-value for nonexistent files)
  • FingerprintFromBytes — computes fingerprint from raw bytes
  • Write(path, data, fingerprint) — main API with TOCTOU protection
  • ErrConcurrentModification sentinel error for fingerprint mismatch detection
  • File permission preservation from existing file (defaults to 0644 for new files)
  • xxhash64 vs SHA-256 benchmarks demonstrating ~11× speed advantage
  • Unit tests, permission preservation tests, and concurrent writer contention test

Note: The .bak two-rename pattern in this release was later found to be non-atomic. It was fixed in v0.2.0.