package tools import ( "fmt" "os/exec" "strings" ) func GetGitRoot() (string, error) { cmd := exec.Command("git", "rev-parse", "--show-toplevel") out, err := cmd.Output() if err != nil { return "", err } lines := strings.Split(string(out), "\n") if lines[0] == "" { return "", fmt.Errorf("unable to determine root directory from git") } return lines[0], nil }