util: use assets from embeded FS
continuous-integration/drone/push Build was killed Details

This commit is contained in:
nemunaire 2021-07-06 21:15:02 +02:00
parent f8dfd4e08b
commit 7be1eec9fa
2 changed files with 8 additions and 1 deletions

View File

@ -14,6 +14,10 @@ var _assets embed.FS
var Assets http.FileSystem
func GetEmbedFS() embed.FS {
return _assets
}
func init() {
sub, err := fs.Sub(_assets, "dist")
if err != nil {

View File

@ -35,9 +35,12 @@ import (
"bytes"
"flag"
"io"
"io/fs"
"net/mail"
"text/template"
"git.happydns.org/happydns/ui"
gomail "github.com/go-mail/mail"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
@ -135,7 +138,7 @@ func SendMail(to *mail.Address, subject, content string) (err error) {
return
}
if data, err := Asset("htdocs/dist/img/happydns.png"); err != nil {
if data, err := fs.ReadFile(ui.GetEmbedFS(), "dist/img/happydns.png"); err != nil {
m.EmbedReader("happydns.png", bytes.NewReader(data))
}