Wojciech Kwolek
a1a55bf8d2
however, go 1.16 is now required (it is quite ancient anyway at this point)
32 lines
503 B
Go
32 lines
503 B
Go
package memelibrary
|
|
|
|
import (
|
|
"embed"
|
|
"path"
|
|
)
|
|
|
|
//go:embed assets
|
|
var content embed.FS
|
|
|
|
func AssetDir(name string) ([]string, error) {
|
|
entries, err := content.ReadDir(path.Join("assets", name))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
files := make([]string, len(entries))
|
|
for i, entry := range entries {
|
|
files[i] = entry.Name()
|
|
}
|
|
|
|
return files, nil
|
|
}
|
|
|
|
func MustAsset(name string) []byte {
|
|
data, err := content.ReadFile(path.Join("assets", name))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return data
|
|
}
|