Goal: I'd like to copy-in/compile-in all the files that would normally live on disk, putting them into the go executable file.
Rationale: for easy (single executable binary, in classic Go style) distribution of all the required files and directories that attend the CGO called code.
Constraint: Ideally the C code in the libraries wouldn't have to be modified in order to redirect its access to the filesystem embedded inside the binary.
Q: Is there an existing "filesystem within a file" library for Go? I'd like OSX and linux support.
I imagine I could use LD_PRELOAD / DYLD_INSERT_LIBRARIES to hook open/read/write calls and redirect them to the internal data. But then I still need to have a "filesystem within a file" directory structure logic implemented that lets me embed that filesystem in the file somewhere. The filesystem can be read-only.
Are there any existing libraries or parts for such a job?
Caveat: I'd prefer to avoid the complexity and installation requirements of a container/Docker/docker data volume.
I'm currently thinking I may need to resort to a single external database file. Perhaps this file is managed by boltdb or bazil, then use LD_PRELOAD -> hook filesystem open(),, read(), write() filesystem calls, and redirect the filesystem operations that are to the "internal paths" to the single-file database.