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 package aid
import ( import (
"os"
"strconv" "strconv"
"strings" "strings"
@ -35,15 +34,10 @@ var (
Config *CS Config *CS
) )
func LoadConfig() { func LoadConfig(file []byte) {
Config = &CS{} Config = &CS{}
configPath := "config.ini" cfg, err := ini.Load(file)
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")
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

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