-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 go:embed for embedding files instead of vfsgen #17352
Comments
only we will have to do some restucture of code as you can not embed files that are not in the same directory or in child directory where golang code is where you are embedding it. |
go:embed don't support |
Maybe symlink before build? |
We can add a small go file in those locations to grab the assets. |
Another thing to consider is that vfsgen provides the gzip versions of assets which we directly serve from the http server if the client indicates gzip support. I think it's crucial for performance to retain the option to serve pre-compiled gzip assets. Edit: See https://github.com/vearutop/statigz for one approach to solve it. I also maintain a JS module to generate |
Hey @techknowlogick , I would love to contribute to this issue under Hacktoberfest. How can I get started? |
the main concern is that if we ose std embeded the compressed files would be decompressed and compressed on each request that indicated gzip support ... ... @techknowlogick should we close this issue? |
There could be a comment in code for why the vfsgen is chosen, to help future developers know the background. Otherwise months later the knowledge may be lost. |
As well, this is still a valid issue. silverwind posted above a potential https://github.com/vearutop/statigz that allows serving embedded files via gzip |
Yes, I think it's still a goal to use |
We really need to migrate to
If we have |
Doesn't vfsgen have done that? |
Yes, but only gzip. We want Brotli as well for another ~30% size reduction over gzip. Using |
Are we fine with dropping support for non-bindata builds (e.g. always embed, don't support non-embedded assets in the file system, except custom files). I fail to see a real use case for non-bindata builds and it just complicates the implementation a lot. |
Assuming |
Indeed, watch mode depends on files in the file system. One solution is to have go run a reverse proxy on the |
Done in #22887 |
go:embed is part of the standard library and does not require an extra go:generate step. Migrate all usages of bindata to go:embed. Make embedded the new default (previously required bindata tag). Add new tag "servedynamic" which serves from filesystem (old !bindata). Accept-Encoding compression has been dropped. The assets in go:embed are not available in a compressed form. The compression could be enabled again by adding a compress middleware: https://github.com/vearutop/statigz Drop vfsgen dependency (no longer required). Fixes go-gitea#17352 Signed-off-by: Christian Stewart <christian@paral.in>
Feature Description
Now that we have a minimum of go1.16 set, we can use go's embed functionality to embed templates/web assets (css/js), and translations.
Screenshots
No response
The text was updated successfully, but these errors were encountered: