code: func AtomicWriteFile(filename string, data []byte, perm os.FileMode) error {
  	f, err := NewAtomicFileWriter(filename, perm)
  	if err != nil {
  		return err
  	}
  	n, err := f.Write(data)
  	if err == nil && n < len(data) {
  		err = io.ErrShortWrite
  		f.(*atomicFileWriter).writeErr = err
  	}
  	if err1 := f.Close(); err == nil {
  		err = err1
  	}
  	return err
  }
docs: // AtomicWriteFile atomically writes data to a file named by filename.