feat: 支持指定Config位置
This commit is contained in:
@@ -3,7 +3,6 @@ package global
|
|||||||
import (
|
import (
|
||||||
"autoLogin/models"
|
"autoLogin/models"
|
||||||
"github.com/Mmx233/config"
|
"github.com/Mmx233/config"
|
||||||
"github.com/Mmx233/tool"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
@@ -11,7 +10,7 @@ import (
|
|||||||
var Config models.Config
|
var Config models.Config
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
tool.File.Options.ForceRoot = true
|
initFlags()
|
||||||
|
|
||||||
//配置文件初始化
|
//配置文件初始化
|
||||||
if e := config.Load(config.Options{
|
if e := config.Load(config.Options{
|
||||||
@@ -31,7 +30,7 @@ func init() {
|
|||||||
Timeout: 1,
|
Timeout: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Path: "Config.json",
|
Path: Flags.Path,
|
||||||
FillDefault: true,
|
FillDefault: true,
|
||||||
Overwrite: true,
|
Overwrite: true,
|
||||||
}); e != nil {
|
}); e != nil {
|
||||||
|
|||||||
12
global/flags.go
Normal file
12
global/flags.go
Normal 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()
|
||||||
|
}
|
||||||
2
go.mod
2
go.mod
@@ -4,7 +4,7 @@ go 1.16
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Mmx233/config v0.0.3
|
github.com/Mmx233/config v0.0.3
|
||||||
github.com/Mmx233/tool v0.2.5
|
github.com/Mmx233/tool v0.2.6
|
||||||
github.com/PuerkitoBio/goquery v1.7.1 // indirect
|
github.com/PuerkitoBio/goquery v1.7.1 // indirect
|
||||||
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf // indirect
|
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -1,7 +1,7 @@
|
|||||||
github.com/Mmx233/config v0.0.3 h1:E744hob5fWD5P7m7q+91Z41R+Y1LDkxIhQXIeV1tel0=
|
github.com/Mmx233/config v0.0.3 h1:E744hob5fWD5P7m7q+91Z41R+Y1LDkxIhQXIeV1tel0=
|
||||||
github.com/Mmx233/config v0.0.3/go.mod h1:3mt+LSHUvD/C6tq1ge/Dmp8xKivFmo7gxSihCPjIAi0=
|
github.com/Mmx233/config v0.0.3/go.mod h1:3mt+LSHUvD/C6tq1ge/Dmp8xKivFmo7gxSihCPjIAi0=
|
||||||
github.com/Mmx233/tool v0.2.5 h1:48iYgydVhoqDqeVXKBXS6WALRbp/0W3WRalo4/yV/xY=
|
github.com/Mmx233/tool v0.2.6 h1:kby/EOdP2YzATLi/s6y0lWNNYDXDidMSUIyYm8AcS4s=
|
||||||
github.com/Mmx233/tool v0.2.5/go.mod h1:un5MCoI21lH40fFI5S9++aja8nJb+2sjATak7PnGMZ0=
|
github.com/Mmx233/tool v0.2.6/go.mod h1:un5MCoI21lH40fFI5S9++aja8nJb+2sjATak7PnGMZ0=
|
||||||
github.com/PuerkitoBio/goquery v1.7.1 h1:oE+T06D+1T7LNrn91B4aERsRIeCLJ/oPSa6xB9FPnz4=
|
github.com/PuerkitoBio/goquery v1.7.1 h1:oE+T06D+1T7LNrn91B4aERsRIeCLJ/oPSa6xB9FPnz4=
|
||||||
github.com/PuerkitoBio/goquery v1.7.1/go.mod h1:XY0pP4kfraEmmV1O7Uf6XyjoslwsneBbgeDjLYuN8xY=
|
github.com/PuerkitoBio/goquery v1.7.1/go.mod h1:XY0pP4kfraEmmV1O7Uf6XyjoslwsneBbgeDjLYuN8xY=
|
||||||
github.com/andybalholm/cascadia v1.2.0 h1:vuRCkM5Ozh/BfmsaTm26kbjm0mIOM3yS5Ek/F5h18aE=
|
github.com/andybalholm/cascadia v1.2.0 h1:vuRCkM5Ozh/BfmsaTm26kbjm0mIOM3yS5Ek/F5h18aE=
|
||||||
|
|||||||
Reference in New Issue
Block a user