snippetgoModerate
How to embed files into Go binaries
Viewed 0 times
howembedfilesbinariesinto
Problem
I have some text file that I read from my Go program. I'd like to ship a single executable, without supplying that text file additionally.
How do I embed it into compilation on Windows and Linux?
How do I embed it into compilation on Windows and Linux?
Solution
Use go-bindata. From the README:
This tool converts any file into managable Go source code. Useful for
embedding binary data into a go program. The file data is optionally
gzip compressed before being converted to a raw byte slice.
This tool converts any file into managable Go source code. Useful for
embedding binary data into a go program. The file data is optionally
gzip compressed before being converted to a raw byte slice.
Context
Stack Overflow Q#17796043, score: 32
Revisions (0)
No revisions yet.