JavaRush
AI Academy
new
Promotion
Learning
Courses
Tasks
Quizzes
Games
Help
Schedule of nudges
Internship
Community
Users
Forum
Chat
Articles
Activities
Reviews
Subscriptions
Light theme

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • Why a simple file overwrite is dangerous

    Go SELF
    42 level,0 lecture
    We break down why a naive overwrite via os.WriteFile or os.Create can lead to a “half-version” of a file: the critical truncate point, partial writes ( Write returns ( n , err )), buffering, and the required protocol steps Flush () and Close (). We formulate invariants for reliable writes, discuss the storage contract ( Load/ Save), and cover typical error-handling mistakes in Go.
    Open
  • temp file + rename pattern: atomic file update

    Go SELF
    42 level,1 lecture
    We break down a practical protocol for atomically overwriting a file using the temp file + rename pattern: why it is not enough to “just call” os.WriteFile, where errors really surface ( Flush()/ Sync()/ Close()), why a temporary file should be created next to the target via os.CreateTemp, and how to publish the result via os.Rename without losing errors and without leaving junk behind.
    Open
  • Backup .bak: a creation and restore strategy

    Go SELF
    42 level,2 lecture
    We’ll break down a practical “one step back” backup policy: why a .bak file is useful even with the temp + rename protocol, how to correctly integrate a backup into the operation order (create .bak before publishing), and how to implement write/rollback in Go via the WriteWithBackup, rotateBackup, and RestoreFromBackup functions.
    Open
  • Two processes write at the same time

    Go SELF
    42 level,3 lecture
    We break down why reliable writing via temp + rename does not prevent lost updates with two parallel processes, and how an agreement via a lock-file helps serialize the entire read → compute → write cycle. In practice, we implement AcquireLock/ Release using os . OpenFile and flags O_CREATE | O_EXCL, discuss limitations (a stuck lock) and typical mistakes.
    Open
  • Storage testability: scenarios with t.TempDir()

    Go SELF
    42 level,4 lecture
    We break down how to write reproducible tests for file-based storage in Go: isolation via t.TempDir(), designing an API “for testing” (path as a parameter, returning error), checking result invariants (file content, no garbage like .tmp-*, correct .bak behavior), test helpers with t.Helper(), table-driven cases, and a basic lock-file scenario via AcquireLock().
    Open
Learn
  • Registration
  • Java course
  • Help with tasks
  • Pricing
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Activities
Company
  • About us
  • Contacts
  • Reviews
  • FAQ
  • Support
JavaRushJavaRush — is an interactive online course for learning Java programming from scratch. It contains 1200 practical tasks with one-click solution checking, the necessary minimum of theory on Java basics, and motivating features that help you complete the course: games, quizzes, interesting projects and articles on effective learning and the career of a Java developer.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush
MastercardVisa
"Programmers are not born" © 2026 JavaRush