Add config.ini into binary! (0 external files needed once built)
This commit is contained in:
parent
8dac330306
commit
98a30263a6
|
@ -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)
|
||||
}
|
||||
|
|
7
main.go
7
main.go
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user