fix:修复在crontab等中配置文件路径异常的问题

This commit is contained in:
Mmx
2021-03-24 21:54:00 +08:00
parent 31c7be1efd
commit 487c22846a
2 changed files with 7 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import (
"Mmx/Modles"
"fmt"
"os"
"path/filepath"
)
type config struct {
@@ -30,6 +31,11 @@ func (*config) Generate(Form *Modles.LoginForm, Meta *Modles.LoginMeta) *Modles.
}
func (a *config) Init() *Modles.LoginInfo {
if t, err := os.Executable(); err != nil {
ErrHandler(err)
} else {
a.Path = filepath.Dir(t) + "/" + a.Path
}
if !File.Exists(a.Path) {
if err := File.Write(a.Path, &Modles.Config{ //默认值
From: Modles.LoginForm{

2
go.mod
View File

@@ -1,3 +1,3 @@
module Mmx
go 1.15
go 1.16