go - Golang ...字符串类型arg函数
问题描述
为什么我不能将 args 放入函数中
func ex(c string,ex ...string) { exec.Command(c,ex) }
得到错误cannot use args (type []string) as type string
。为什么?
解决方案
您可以ex...
在语句中使用:exec.Command(c,ex...)
而不仅仅是ex
下面作为一个例子:
func ex(c string,ex ...string) { exec.Command(c,ex...) }
推荐阅读
- android - 为 ViewModel 创建单元测试
- javascript - Web 组件:如何监听表单输入的变化
- python - 从 python (jupyter notebook) 导入 R 库时出现问题,它返回错误“rpy2.rinterface.NULL”
- r - 使用 REAT 包中的 locq2 时出错,“要替换的项目数不是替换长度的倍数”
- java - @CrossOrigin 无法使用 Spring Boot。我该如何修复它?
- jsonschema - 导入模式但重新定义定义
- regex - 如何匹配特定字符串后的数字而没有积极的回溯?
- java - 有没有办法在每次迭代中使用递增数字作为对具有不同数字的方法的调用
- python - ReadFromPubSub->CloudStorage->BigQuery:订阅的大小永远不会减少,而且似乎只有 0.002% 的订阅到达 BigQuery
- microsoft-graph-api - 连接到 Graph API 以获得教育应用程序权限