gpt4 book ai didi

go - fork /执行。没有这样的文件或目录退出状态 1

转载 作者:数据小太阳 更新时间:2023-10-29 03:03:10 26 4
gpt4 key购买 nike

我在 Mac (darwin/amd64) 上使用 Go 1.10.2 并遇到这个错误。它说没有这样的文件或目录。

这是我的代码,

func loop1(gor_name string, ras_ip string) {
var a string
var c string
a = search_path()
fmt.Printf("当前路径为", a)
fmt.Println(os.Chdir(a))

c = fmt.Sprintf("%s %s %s %s", "./goreplay --input-file ", gor_name, " --input-file-loop --output-http ", ras_ip)
fmt.Printf("c: ", c)
cmd := exec.Command(c)
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
channel <- 1

}

非常感谢您的任何建议。

最佳答案

exec.Command 的函数签名是:

func Command(name string, args ...string) *Cmd

其中 name 是程序的名称,args 是参数。试试这个:

cmd := exec.Command("./goreplay", "--input-file", gor_name, "--input-file-loop", "--output-http", ras_ip)

关于go - fork /执行。没有这样的文件或目录退出状态 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50285231/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com