Shell 从go中的exec.Command运行时,google chrome找不到现有用户配置文件

Shell 从go中的exec.Command运行时,google chrome找不到现有用户配置文件,shell,google-chrome,go,Shell,Google Chrome,Go,从my shell运行时,以下命令按预期工作,在chrome的特定用户配置文件中打开google.com。 /home/myuser/.nix profile/bin/google chrome beta google.com--profile directory=“profile 3” 但是 当通过goexec.command调用等效命令时,会打开相应的链接,但它会创建一个新的用户配置文件。我不知道为什么。新的用户配置文件是在现有的chrome数据目录中创建的,因此chrome没有使用错误的-

从my shell运行时,以下命令按预期工作,在chrome的特定用户配置文件中打开google.com。
/home/myuser/.nix profile/bin/google chrome beta google.com--profile directory=“profile 3”

但是

当通过go
exec.command
调用等效命令时,会打开相应的链接,但它会创建一个新的用户配置文件。我不知道为什么。新的用户配置文件是在现有的chrome数据目录中创建的,因此chrome没有使用错误的
--user data dir
。将“
--profile directory”
标记保留在go中会打开默认chrome配置文件中的链接(这是预期的)。我就是不明白为什么在
exec.Command

package main

import (
    "os/exec"
)

func main() {
    c := exec.Command(`/home/myuser/.nix-profile/bin/google-chrome-beta`, `google.com`, `--profile-directory="Profile 3"`)
    c.Run()
}
编辑:

通过切换语言,我可以自己解决这个问题。我决定在rust中尝试同样的方法,查找如何在rust中执行我发现了许多使用
sh-c
作为命令的示例。我尝试在rust中使用
std::process::Command
,并能够使它按预期工作。在rust中直接调用google chrome测试版也会导致同样的问题。然而,由于某些原因,在go中对exec.Command使用
sh-c
并不能解决我的问题:noidea:

也许您需要设置一个合适的工作目录?不过不确定