判断配置文件是否存在
This commit is contained in:
parent
41293c6d47
commit
01f4d175a0
25
main.go
25
main.go
@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
@ -98,12 +99,34 @@ func SubProcess(args []string) *exec.Cmd {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func get_ini() string {
|
||||
exePath, err := os.Executable()
|
||||
if err != nil {
|
||||
fmt.Println("无法获取可执行文件路径:", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
exeDir := filepath.Dir(exePath)
|
||||
exeDir = filepath.Join(exeDir, "public_ip.ini")
|
||||
fmt.Println(exeDir)
|
||||
|
||||
return exeDir
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
var version = "1.0.0"
|
||||
|
||||
// 获取当前可执行文件的路径
|
||||
INI_FILE := get_ini()
|
||||
_, err := os.Stat(INI_FILE)
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Println("配置文件不存在")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// 读取配置文件
|
||||
cfgs, err := ini.Load("public_ip.ini")
|
||||
cfgs, err := ini.Load(INI_FILE)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
@ -3,11 +3,11 @@
|
||||
Get_Find_Ip_Url="http://58.34.44.125:6108/ip/find/ip/url"
|
||||
|
||||
# 获取公网Ip后需要发送的Url地址
|
||||
SedIpURL="http://58.34.44.125:6108/ip/set/ip?ip=%s&storeNo=%s"
|
||||
SedIpURL="http:// 58.34.44.125:6108/ip/set/ip?ip=%s&storeNo=%s"
|
||||
|
||||
# 门店编号
|
||||
StoreNo=2
|
||||
|
||||
# 等待时间
|
||||
While_Time=20
|
||||
While_Time=60
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user