执行:将字符串与exec.Command一起使用时出现奇怪的结果

I have a Go function that processes Linux CLI commands and their arguments:

func cmd(cmd string, args ...string) ([]byte, error) {
    path, err := exec.Command("/usr/bin/which", cmd).Output()
    if err != nil {
        return []byte(""), err
    }
    response, err := exec.Command(string(path), args...).Output()
    if err != nil {
        response = []byte("Unknown")
    }
    return response, err
}

Which is called by the following:

func main() {
    uname, err := cmd("uname", "-a")
    fmt.Println(string(uname))
}

The "which" command returns the correct path to the binary but when it tries to run the second exec command with a dynamic path the return is always:

fork/exec /usr/bin/uname
: no such file or directory
exit status 1

Yet if the second exec command is hardcoded, everything works as expected and prints the uname:

response, err := exec.Command("/usr/bin/uname", args...).Output()

Am I missing something about how exec and strings behave?

Thanks

The which command prints a newline following the name of the executable. The path variable is set to "/usr/bin/uname ". There is no executable with this path. The extra newline is visible in the error message (the newline just before the ":").

Trim the newline suffix to get the correct name of the executable:

 response, err := exec.Command(strings.TrimSuffix(string(path), "
"), args...).Output()