Skip to content

Commit

Permalink
fix:修复在crontab等中配置文件路径异常的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Mmx committed Mar 24, 2021
1 parent 31c7be1 commit 487c228
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"Mmx/Modles"
"fmt"
"os"
"path/filepath"
)

type config struct {
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Mmx

go 1.15
go 1.16

0 comments on commit 487c228

Please sign in to comment.