使用此代码但它给出了卷曲:(3) URL 使用错误/非法格式或缺少 URL 卷曲:(3) URL 使用错误/非法格式或运行 golang 代码时缺少 URL
cmd := exec.Command("curl", " -F", " tarball=@"+tgzpath, " --request", " POST", " -H", fmt.Sprintf("Authorization: Bearer %s", Token )," ","http://localhost:1880/nodes")
same command is working fine in local - curl -F tarball=@/tgzpath --request POST -H "Authorization: Bearer Token" http://localhost:1880/nodes
试过上面的代码,但它也给出了未经授权的错误
你应该删除参数中的所有前导空格:
cmd := exec.Command("curl", "-trace", "-F", "tarball=@"+tgzpath, "--request", "POST", "-H", fmt.Sprintf("Authorization: Bearer %s", Token), "https://httpbin.org/get/200")
请看下面
-F
和-F
的区别:
$ curl " -F"
curl: (3) URL using bad/illegal format or missing URL
$ curl "-F"
curl: option -F: requires parameter
curl: try 'curl --help' or 'curl --manual' for more information