英文:
Packing multiple images into a GOLANG binary
问题
GOLANG 高手们:
我知道这可能看起来不合逻辑,但还是请听我说。
我需要将一个二进制文件(在这种情况下是一个 web 服务器)分发给其他工程师进行测试。为了简化操作,因为他们可能不是开发人员,我想知道是否有一种自动化的方式可以将图像打包到 GOLANG 二进制文件中?我以前在静态 HTML 页面上做过这样的操作,效果很好。
显然,第一次运行时我可以解压到文件系统中,但为了保持整洁,我想知道是否有人有任何想法,如何将它们塞进二进制文件中。
有什么想法吗?
英文:
GOLANG gurus:
I know this might seem illogical, but here it goes.
I have to distribute a binary (which in this case would be a webserver) to other engineers for testing. To keep it simple, because they might not be developers, I wanted to see if there might be some automated way to pack images into a GOLANG binary ? I've done this static HTML pages in the past, and it works great.
Obviously, at first run I could unzip to the file system, but to keep things clean I was trying to see if anyone has any thoughts how I could stuff them into a binary.
Any Ideas ?
答案1
得分: 3
你可以使用与HTML文件相同的工具...我假设你使用了类似以下的工具:
- https://github.com/jteeuwen/go-bindata
- https://github.com/GeertJohan/go.rice
- https://github.com/mjibson/esc
- https://github.com/rakyll/statik
- 等等
这些工具基本上会将你的文件转换为Go源代码,并提供类似http.FileSystem的API来读取你的数据。
英文:
You could use the same tools you used for HTML files... I'm assuming you used something like:
- https://github.com/jteeuwen/go-bindata
- https://github.com/GeertJohan/go.rice
- https://github.com/mjibson/esc
- https://github.com/rakyll/statik
- etc.
Which essentially transform your files in go source code and the expose an http.FileSystem-like API for reading your data.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论