func OpenFileInEditor(filename string, resolveEditor PreferredEditorResolver) error {
	executable, err := exec.LookPath(resolveEditor())
	if err != nil {
		return err
	}
	cmd := exec.Command(executable, resolveEditorArguments(executable, filename)...)
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	return cmd.Run()
}
OpenFileInEditor opens filename in a text editor.
package editor
import (
	"io/ioutil"
	"os"
	"os/exec"
	"runtime"
	"strings"
)
const DefaultEditor = "vim"
type PreferredEditorResolver func() string
func GetPreferredEditorFromEnvironment() string {
	if runtime.GOOS == "windows" {
		return "notepad.exe"
	}
	editor := os.Getenv("EDITOR")
	if editor == "" {
		return DefaultEditor
	}
	return editor
}
func resolveEditorArguments(executable string, filename string) []string {
	args := []string{filename}
	if strings.Contains(executable, "Visual Studio Code.app") {
		args = append([]string{"--wait"}, args...)
	}
	return args
}