登录
首页 >  Golang >  Go问答

Config.toml 文件在 CLI Go 中的位置

来源:stackoverflow

时间:2024-03-07 22:30:26 356浏览 收藏

大家好,今天本人给大家带来文章《Config.toml 文件在 CLI Go 中的位置》,文中内容主要涉及到,如果你对Golang方面的知识点感兴趣,那就请各位朋友继续看下去吧~希望能真正帮到你们,谢谢!

问题内容

我尝试在虚拟机上部署之前通过 -bash cli 在本地测试 golang 应用程序 hauser

根据文档,我在本地编译并复制了 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

一般来说,使用绝对路径更容易。

好了,本文到此结束,带大家了解了《Config.toml 文件在 CLI Go 中的位置》,希望本文对你有所帮助!关注golang学习网公众号,给大家分享更多Golang知识!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>