code: func saveCheckpoint(checkpointFile, id string) error {
  	tmpDir, err := ioutil.TempDir("", "checkpoint-tmp")
  	if err != nil {
  		return err
  	}
  	defer func() { _ = os.RemoveAll(tmpDir) }()
  	tmp, err := ioutil.TempFile(tmpDir, "checkpoint-atomic")
  	if err != nil {
  		return err
  	}
  	if _, err = tmp.Write([]byte(id)); err != nil {
  		return err
  	}
  	return os.Rename(tmp.Name(), checkpointFile)
  }
docs: // saveCheckpoint atomically writes the provided ID to the provided file. The
  // method os.Rename makes use of the renameat syscall to atomically replace
  // one file with another. It creates a temporary file in a temporary directory
  // before using os.Rename to replace the old file with the new one.