Added embedres.
- Exposes embed.FS (native) as a ui.Resources.
This commit is contained in:
parent
bcd32f8372
commit
5a4dcd52b0
24
addons/embedres/embedres.go
Normal file
24
addons/embedres/embedres.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package embedres
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"opslag.de/schobers/zntg/ui"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ ui.Resources = &resources{}
|
||||||
|
|
||||||
|
type resources struct {
|
||||||
|
fs embed.FS
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(fs embed.FS) ui.Resources {
|
||||||
|
return &resources{fs}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r resources) Destroy() error { return nil }
|
||||||
|
|
||||||
|
func (r resources) OpenResource(name string) (io.ReadCloser, error) {
|
||||||
|
return r.fs.Open(name)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user