func Run(srcPath string, outputPath string, mode Method, unexported bool) error {
	mainBuf, testsBuf, err := RunData(srcPath, mode, unexported)
	if err != nil {
		return err
	}
	if outputPath != "" {
		pre := strings.TrimPrefix(outputPath, srcPath)
		if len(pre) > 0 && !strings.HasSuffix(outputPath, ".go") {
			outputPath = filepath.Join(srcPath, outputPath)
		}
	} else if stat, err := os.Stat(srcPath); err == nil && stat.IsDir() {
		outputPath = filepath.Join(srcPath, "msgp_gen.go")
	} else {
		outputPath = strings.TrimSuffix(srcPath, ".go") + "_gen.go"
	}
	doneErr := make(chan error, 1)
	go func() {
		doneErr <- formatWrite(outputPath, mainBuf.Bytes())
	}()
	if testsBuf != nil {
		testFileName := strings.TrimSuffix(outputPath, ".go") + "_test.go"
		if err := formatWrite(testFileName, testsBuf.Bytes()); err != nil {
			return err
		}
	}
	return <-doneErr
}
Run writes your desired methods and test files. You must set the source code path. The output file
path can be left blank to have a file created at old_name_gen.go (_gen appended to the old name; the
test file, if you opt to create one, will be at old_name_gen_test.go). The mode is the set of Method
types and tests you would like. Set unexported to true if you want code to be generated for unexported
as well as for exported types.
package gen
import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	"github.com/ttacon/chalk"
	"golang.org/x/tools/imports"
)