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

Embed sources at compile time #7

Open
samber opened this issue May 18, 2023 · 3 comments
Open

Embed sources at compile time #7

samber opened this issue May 18, 2023 · 3 comments

Comments

@samber
Copy link
Owner

samber commented May 18, 2023

It would be helpful to embed source code in binary, since the .Sources() getter read the sources at runtime, at location specified in the stack trace.

I don't see any developer-friendly way to do it, except by using an extra compilation step or codegen. 🙄

The best scenario would be to enable/disable it with a flag in the compilation line or with an environment variable.

Example:

OOPS_EMBED_SOURCES="none" // default
OOPS_EMBED_SOURCES="minimal"   // project
OOPS_EMBED_SOURCES="all"  // project + dependencies (very heavy!!)

Any idea ?

@elliotcourant
Copy link

It might be easier to just allow the code that derives the actual source to use the embed.FS interface (or whatever its called). Then have an implementation of the interface that uses the actual filesystem or if the user of the library provides an embedded interface it can use that.

I'm looking to add something similar to the sentry-go SDK for the same reason, as distributing an app as a binary is a lot easier than co-locating the source code.

@samber
Copy link
Owner Author

samber commented Dec 19, 2023

OK, I'm interested in your experiments. If you find a simple and reliable way to implement it, i would be happy to add it to oops.

@elliotcourant
Copy link

Let me mess around a bit, I'm going to try to add this to sentry-go first but the implementation should be identical.

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

2 participants