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 go:embed for embedding files instead of vfsgen #17352

Open
techknowlogick opened this issue Oct 18, 2021 · 6 comments
Open

Use go:embed for embedding files instead of vfsgen #17352

techknowlogick opened this issue Oct 18, 2021 · 6 comments

Comments

@techknowlogick
Copy link
Member

@techknowlogick techknowlogick commented Oct 18, 2021

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

@lafriks
Copy link
Member

@lafriks lafriks commented Oct 18, 2021

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.

@lunny
Copy link
Member

@lunny lunny commented Oct 19, 2021

go:embed don't support ../ on path, the directory structure have to be changed.

@techknowlogick techknowlogick changed the title Use go:embed for embedding files instead of vfsfen Use go:embed for embedding files instead of vfsgen Oct 19, 2021
@silverwind
Copy link
Member

@silverwind silverwind commented Oct 19, 2021

Maybe symlink before build?

@jolheiser
Copy link
Member

@jolheiser jolheiser commented Oct 19, 2021

We can add a small go file in those locations to grab the assets.

@silverwind
Copy link
Member

@silverwind silverwind commented Oct 19, 2021

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 .gz and .br files at https://github.com/silverwind/precompress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants