code: func (o Output) Write(dir string) (changed, unchanged []string, err error) {
  	// First pass: populate 'changed' and 'unchanged', so we have a valid result
  	// even when failing midway through writes.
  	changed, unchanged = o.Compare(dir)
  
  	// Second pass: update changed files.
  	for _, name := range changed {
  		path := filepath.Join(dir, filepath.FromSlash(name))
  		if err = os.MkdirAll(filepath.Dir(path), 0777); err != nil {
  			return
  		}
  		if err = ioutil.WriteFile(path, o.Data[name], 0666); err != nil {
  			return
  		}
  	}
  
  	return
  }
docs: // Write updates files on disk to match the output.
  //
  // Returns a list of updated files and a list of files that are already
  // up-to-date, same as Compare.
  //
  // Creates missing directories. Not atomic. All files have mode 0666.