func compareFiles(pathA, pathB string) error {
	contentA, err := ioutil.ReadFile(pathA)
	if err != nil {
		return err
	}
	contentB, err := ioutil.ReadFile(pathB)
	if err != nil {
		return err
	}
	if !bytes.Equal(contentA, contentB) {
		output := new(bytes.Buffer)
		output.WriteString(fmt.Sprintf("%q and %q are not equal!\n\n", pathA, pathB))
		diffPath, err := exec.LookPath("diff")
		if err != nil {
			return nil
		}
		diffCmd := exec.Command(diffPath, pathA, pathB)
		diffCmd.Stdout = output
		diffCmd.Stderr = output
		output.WriteString("$ diff " + pathA + " " + pathB + "\n")
		if err := diffCmd.Run(); err != nil {
			output.WriteString("\n" + err.Error())
		}
		return errors.New(output.String())
	}
	return nil
}
compareFiles compares the content of files with pathA and pathB.
If contents are equal, it returns nil.
If not, it returns which files are not equal
and diff (if system has diff command) between these files.
package cmd
import (
	"bytes"
	"errors"
	"flag"
	"fmt"
	"io/ioutil"
	"os/exec"
)
var update = flag.Bool("update", false, "update .golden files")
func init() {
	addCmd.SetOutput(new(bytes.Buffer))
	initCmd.SetOutput(new(bytes.Buffer))
}