fix auto config defile

This commit is contained in:
xxjwxc
2020-02-23 14:42:20 +08:00
parent 1211376025
commit 2aa5bb804d
4 changed files with 18 additions and 22 deletions

View File

@@ -2,11 +2,13 @@ package config
import (
"fmt"
"io/ioutil"
"os"
"path"
"github.com/xxjwxc/public/dev"
"github.com/xxjwxc/public/tools"
"gopkg.in/yaml.v3"
"io/ioutil"
"os"
)
// CfgBase base config struct
@@ -42,10 +44,10 @@ var _map = Config{
IsGUI: false,
}
var configPath string = "gormt.yml"
var configPath string
func init() {
// configPath = path.Join(tools.GetModelPath(), "config.yml")
configPath = path.Join(tools.GetModelPath(), "config.yml")
onInit()
dev.OnSetDev(_map.IsDev)
}
@@ -61,11 +63,11 @@ func onInit() {
// InitFile default value from file .
func InitFile(filename string) error {
if _, e := os.Stat(filename); e != nil {
fmt.Println("配置文件未初始化,正在自动初始化配置文件", filename)
fmt.Println("init default config file", filename)
if err := SaveToFile(); err == nil {
fmt.Println("配置文件初始化完毕")
fmt.Println("done,please restart.")
} else {
fmt.Println("配置文件初始化异常", err)
fmt.Println("shit,fail", err)
}
os.Exit(0)
}