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

Embedded static resources #133

Closed
System-Glitch opened this issue Mar 3, 2021 · 2 comments
Closed

Embedded static resources #133

System-Glitch opened this issue Mar 3, 2021 · 2 comments
Labels
feature request Request for new feature implementation

Comments

@System-Glitch
Copy link
Member

System-Glitch commented Mar 3, 2021

Proposal

Go's 1.16 new embed feature is great to bundle static resources into the binary, making it easier to distribute it. Currently, the frameworks relies on a non-interfaced filesystem, which makes it a bit harder to use embedded resources. Only the configuration supports it. I would like to provide a solution for developers wanting to embed their files.

  • Create a new handler similar to router.Static(), but taking io/fs.FS as a parameter.
  • Add the ability to use an io/fs.FS to load language files. (This may require a bit of refactoring into the framework so it's possible to load a language file by file)
  • Provide an abstracted version of the helper/filesystem package so it works with io/fs too.
  • Allow Request to use generic file system.

On top of adding the ability to embed files, this would also let developers use virtual filesystems and fetch files from other sources more easily. However, the io/fs packge is still a bit young in my opinion, and lacks interfaces for writable FS. I wouldn't want to create a temporary non-standard interface that will probably not be compatible with a potential future standard one. So for now, this issue will stay on standby until more development on the io/fs package.

Because the embed feature is only available in go 1.16+ and that the io.FS interface is required for what I would like to achieve here, we can't build this into the framework without breaking compatibility with prior versions. I don't want to stop supporting older versions (yet), so we could create an external library. Later on, we could consider merging this library into the framework. With v4, I dropped go versions < 1.16.

Possible drawbacks

None.

Additional information

This issue is a feature proposal and is meant to be discussed. The design is not set yet neither.
It is also a good candidate if you want to contribute to the project.

@System-Glitch System-Glitch added good first issue Good for newcomers feature request Request for new feature implementation labels Mar 3, 2021
@System-Glitch System-Glitch added v5 and removed good first issue Good for newcomers labels Aug 13, 2022
@System-Glitch
Copy link
Member Author

Check how wails v2 handles embedded assets. We could take inspiration from this.

@System-Glitch
Copy link
Member Author

Fully supported in v5.

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

No branches or pull requests

1 participant