我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

如何在运行时读取文本文件

This question already has an answer here:

  • Find the path to the executable 3 answers

Hi I have a program where I want to read files relative to the binary installed in the bin folder. I have looked at using:

filepath.Abs
os.Getwd()

But this only gives me the folder beneath "src" during.




Eventually I will use:

os.Open(abspath)

How do you read files during runtime?

</div>

I had already seen the osext, but now that dyoo mentioned it - I went for it. And it works.

https://godoc.org/bitbucket.org/kardianos/osext

Thanks

近期文章

  • Golang可以安全地切换cmd.Stdout
  • UDP在golang中,监听不是阻止呼叫吗?
  • 解释SetWriteDeadline错误
  • 如何让Heroku检测GO buildpack
  • 使用Golang读取随机内存位置
  • MapReduce中的Golang GlobalSign mgo查询
  • Go-Python的“ pass”等效于什么?
  • 代理https时强制客户端主机名
  • GoLang在字节片的第N行获取字符串
  • 编译器错误将切片附加到切片
  • 区分JSON和其他错误
  • 转到GAE错误:找不到'__main__'模块(Win 8.1)
  • 使用cli Go包读取外部文件
  • Golang:如何将[] string转换为类型化的结构?
  • 转到:使用乘数将float64转换为int
  • 将Go Web服务器部署到Google计算引擎
  • 使用goquery提取元描述字段
  • 如何在Golang中将json数据提供给页面?
  • 从Go结构创建JSON表示形式
  • Go服务器中基于角色的优雅JWT安全性

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华