-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
As described in docs, the //go:embed directive allows us to embed multiple files into a dedicated File System that satisfies the io.FS interface.
I've encountered a situation where I would like to embed (namely hide) certain large images into the executable to load them into the memory at the very start of my application, but as soon as I decode those images (or use embedded files) I don't need them in my memory anymore.
If I set the value of the embed.FS variable to embed.FS{} it would wipe every embedded file from the memory, but there is no way to remove a particular one.
The fs.File returned by embed.FS's Open() does nothing at Close() which is absolutely understandable, that's why I would like to propose a new function in the embed.FS struct that would erase a file (or dir) at given name, my suggestion would be Dispose(name string) error.