code: func (w *AtomicWriter) Close() error {
  	if w.err != nil {
  		return w.err
  	}
  
  	// Try to not leave temp file around, but ignore error.
  	defer w.fs.Remove(w.next.Name())
  
  	if err := w.next.Sync(); err != nil {
  		w.err = err
  		return err
  	}
  
  	if err := w.next.Close(); err != nil {
  		w.err = err
  		return err
  	}
  
  	// Remove the destination file, on Windows only. If it fails, and not due
  	// to the file not existing, we won't be able to complete the rename
  	// either. Return this error because it may be more informative. On non-
  	// Windows we want the atomic rename behavior so we don't attempt remove.
  	if runtime.GOOS == "windows" {
  		if err := w.fs.Remove(w.path); err != nil && !fs.IsNotExist(err) {
  			return err
  		}
  	}
  
  	if err := w.fs.Rename(w.next.Name(), w.path); err != nil {
  		w.err = err
  		return err
  	}
  
  	// fsync the directory too
  	if fd, err := w.fs.Open(filepath.Dir(w.next.Name())); err == nil {
  		fd.Sync()
  		fd.Close()
  	}
  
  	// Set w.err to return appropriately for any future operations.
  	w.err = ErrClosed
  
  	return nil
  }
docs: // Close closes the temporary file and renames it to the final path. It is
  // invalid to call Write() or Close() after Close().