Add config.ini into binary! (0 external files needed once built)

This commit is contained in:
eccentric 2023-12-09 14:32:53 +00:00
parent 8dac330306
commit 98a30263a6
2 changed files with 9 additions and 10 deletions

View File

@ -1,7 +1,6 @@
package aid
import (
"os"
"strconv"
"strings"
@ -35,15 +34,10 @@ var (
Config *CS
)
func LoadConfig() {
func LoadConfig(file []byte) {
Config = &CS{}
configPath := "config.ini"
if _, err := os.Stat(configPath); err != nil {
panic("config.ini not found! please rename default.config.ini to config.ini and complete")
}
cfg, err := ini.Load("config.ini")
cfg, err := ini.Load(file)
if err != nil {
panic(err)
}

View File

@ -1,6 +1,7 @@
package main
import (
_ "embed"
"fmt"
"github.com/ectrc/snow/aid"
@ -11,8 +12,12 @@ import (
"github.com/gofiber/fiber/v2"
)
//go:embed config.ini
var configFile []byte
func init() {
aid.LoadConfig()
aid.LoadConfig(configFile)
var device storage.Storage
switch aid.Config.Database.Type {