我可以在 linux (bash) 上使用:
os.Setenv("TESTKEY", "TestVal")
syscall.Exec(os.Getenv("SHELL"), []string{os.Getenv("SHELL")}, syscall.Environ())
是否可以在 powershell 中做类似的事情?我尝试了各种替代方案,但它们都默默地失败了,例如:
syscall.Exec("PowerShell", []string{"-Command", "Set-Item", "-path", "env:TESTKEY", "-value", "TestVal"}, env)