'go'工具安装可执行文件后如何访问资源文件? [英] How to access resource files after the 'go' tool installed the executable?

查看:128
本文介绍了'go'工具安装可执行文件后如何访问资源文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设运行 go install -v importpath 生成一个可执行文件并将其安装到 $ GOPATH / bin / program go 工具无法安装资源文件。当我运行程序时,我希望它能够访问 $ GOPATH / src / importpath 下的一些资源文件, 。

从安装的可执行文件访问这些资源文件的最佳方式是什么?

解决方案

此问题已被要求多个 <一个href =https://groups.google.com/d/topic/golang-nuts/XksK4klJ0Dg/discussion =nofollow>次在go-nuts邮件列表中。 go 工具目前不提供直接分发更多资源的方式。但是,有两种解决方法可用:


Lets assume that running go install -v importpath builds an executable and installs it into $GOPATH/bin/program. The go tool is unable to install resource files. When I run the program, I would like it to access some resource files that are under $GOPATH/src/importpath.

What is the best way of accessing such resource files from the installed executable?

解决方案

This question has been asked multiple times on the go-nuts mailing list. The go tool doesn't offer a direct way to distribute additional resources at the moment. However, there are two workarounds available:

这篇关于'go'工具安装可执行文件后如何访问资源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆