From f54644e3e9925aaa858eb265a6157a29663bda37 Mon Sep 17 00:00:00 2001 From: eccentric Date: Wed, 8 Nov 2023 22:09:08 +0000 Subject: [PATCH] Add Asset Embedding --- main.go | 2 +- storage/assets/data.json | 1 + storage/embeds.go | 20 ++++++++++++++++++++ store/store.go | 3 --- 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 storage/assets/data.json create mode 100644 storage/embeds.go delete mode 100644 store/store.go diff --git a/main.go b/main.go index 5ce0a45..7897f05 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ import ( ) func init() { aid.LoadConfig() - + var device storage.Storage switch aid.Config.Database.Type { case "postgres": diff --git a/storage/assets/data.json b/storage/assets/data.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/storage/assets/data.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/storage/embeds.go b/storage/embeds.go new file mode 100644 index 0000000..436378d --- /dev/null +++ b/storage/embeds.go @@ -0,0 +1,20 @@ +package storage + +import ( + "embed" + "strings" +) + +var ( + //go:embed assets/* + Assets embed.FS +) + +func Asset(file string) (*[]byte) { + data, err := Assets.ReadFile("assets/" + strings.ToLower(file)) + if err != nil { + return nil + } + + return &data +} \ No newline at end of file diff --git a/store/store.go b/store/store.go deleted file mode 100644 index 2a73001..0000000 --- a/store/store.go +++ /dev/null @@ -1,3 +0,0 @@ -package store - -type Storefront interface{} \ No newline at end of file