如何解决CLI Go Config.toml文件位置
在部署到VM之前,我试图通过-bash CLI在本地测试Golang应用程序hauser
。
对于documentation,我在本地编译并复制了example-config.toml文件。然后,我映射到GOPATH并打开hauser.exe以打开config.toml文件。但是,当我执行时,它返回open config.toml: no such file or directory
C02Z30ANLVDV:~ pmcgin2$ $GOPATH/bin/hauser -c Documents/go/bin/config.toml
2020/08/14 18:05:23 Cannot find folder,make sure it exists
C02Z30ANLVDV:~ pmcgin2$ open Documents/go/bin/config.toml
No application knows how to open /Users/pmcgin2/Documents/go/bin/config.toml.
是否可以执行其他命令来覆盖此类应用程序的默认config.toml位置?
解决方法
有两种方法可以解决您的问题:
- 给出绝对路径作为参数:
$GOPATH/bin/hauser -c /Users/pmcgin2/Documents/go/bin/config.toml
- 从二进制位置给出相对路径:
$GOPATH/bin/hauser -c config.toml
通常,使用绝对路径会更容易。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。