如何使用 golang 在 node-red 中离线安装节点

问题描述 投票:0回答:1

使用此代码但它给出了卷曲:(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

试过上面的代码,但它也给出了未经授权的错误

go node-red
1个回答
1
投票

你应该删除参数中的所有前导空格:

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
© www.soinside.com 2019 - 2024. All rights reserved.