snow/storage/embeds.go
Eccentric 250e85732d feat: update to latest;
new shop system
more config options
arena & hype
per season stats
battle pass
better variant system
complete vbuck & starter pack store
fix bugs related to deleting account
update launcher endpoints
fixed gift loot not deleting
2024-03-10 18:16:42 +00:00

49 lines
690 B
Go

package storage
import (
"embed"
"encoding/json"
"io"
"net/http"
"strings"
)
var (
//go:embed mem/*
Assets embed.FS
)
type snowFS struct {
embed.FS
}
func Asset(file string) (*[]byte) {
data, err := Assets.ReadFile("mem/" + strings.ToLower(file))
if err != nil {
return nil
}
return &data
}
func HttpAsset[T interface{}](file string) (*T) {
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
}
var assetData T
err = json.Unmarshal(data, &assetData)
if err != nil {
return nil
}
return &assetData
}