feat: 支持指定Config位置

This commit is contained in:
Mmx
2021-09-20 09:29:05 +08:00
parent bb45aa9971
commit 48a9785af1
4 changed files with 17 additions and 6 deletions

View File

@@ -3,7 +3,6 @@ package global
import (
"autoLogin/models"
"github.com/Mmx233/config"
"github.com/Mmx233/tool"
"log"
"os"
)
@@ -11,7 +10,7 @@ import (
var Config models.Config
func init() {
tool.File.Options.ForceRoot = true
initFlags()
//配置文件初始化
if e := config.Load(config.Options{
@@ -31,7 +30,7 @@ func init() {
Timeout: 1,
},
},
Path: "Config.json",
Path: Flags.Path,
FillDefault: true,
Overwrite: true,
}); e != nil {

12
global/flags.go Normal file
View File

@@ -0,0 +1,12 @@
package global
import "flag"
var Flags struct {
Path string
}
func initFlags() {
flag.StringVar(&Flags.Path, "config", "", "config path")
flag.Parse()
}