code: func processFile(filename string, in io.Reader, out io.Writer, stdin bool, opts Options) error {
  	if in == nil {
  		f, err := os.Open(filename)
  		if err != nil {
  			return err
  		}
  		defer f.Close()
  		in = f
  	}
  
  	src, err := ioutil.ReadAll(in)
  	if err != nil {
  		return err
  	}
  
  	res, err := printer.Format(src)
  	if err != nil {
  		return fmt.Errorf("In %s: %s", filename, err)
  	}
  
  	if !bytes.Equal(src, res) {
  		// formatting has changed
  		if opts.List {
  			fmt.Fprintln(out, filename)
  		}
  		if opts.Write {
  			err = ioutil.WriteFile(filename, res, 0644)
  			if err != nil {
  				return err
  			}
  		}
  		if opts.Diff {
  			data, err := diff(src, res)
  			if err != nil {
  				return fmt.Errorf("computing diff: %s", err)
  			}
  			fmt.Fprintf(out, "diff a/%s b/%s\n", filename, filename)
  			out.Write(data)
  		}
  	}
  
  	if !opts.List && !opts.Write && !opts.Diff {
  		_, err = out.Write(res)
  	}
  
  	return err
  }
docs: // If in == nil, the source is the contents of the file with the given filename.