Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the new go:embed feature to produce a single, self-contained binary. #6

Open
naikrovek opened this issue Apr 27, 2021 · 0 comments

Comments

@naikrovek
Copy link

naikrovek commented Apr 27, 2021

the //go:embed compiler directive now (since Go 1.16) allows you to embed files into the compiled binary as a read-only filesystem.

This means that you no longer need to have the files you're serving be present in the directory that you're running the executable from; they can be inside the binary itself.

That doesn't matter a lot if you're self-hosting this, but if you want to share it with people and don't want to leave the webserver process running forever on your own machine, sharing a single binary and letting everyone use their own instance is a lot easier.

All I had to do to make this work was change main.go to this:
https://gist.github.com/naikrovek/1ba61a60b66f0bb40dbe105b09cd052e

I don't know what would be needed for the two experimental versions of the tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant