snow/storage/embeds.go
2023-12-10 23:54:31 +00:00

38 lines
533 B
Go

package storage
import (
"embed"
"io"
"net/http"
"strings"
)
var (
//go:embed mem/*
Assets embed.FS
)
func Asset(file string) (*[]byte) {
data, err := Assets.ReadFile("mem/" + strings.ToLower(file))
if err != nil {
return nil
}
return &data
}
func HttpAsset(file string) (*[]byte) {
client := http.Client{}
resp, err := client.Get("https://raw.githubusercontent.com/ectrc/ectrc/main/" + file)
if err != nil {
return nil
}
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil
}
return &data
}