mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 11:07:39 +08:00
fix: More compatible behavior for getting the current executable dir
This commit is contained in:
parent
8389d9195d
commit
532f55fba0
@ -140,7 +140,8 @@ func ResetWorkingDir() {
|
||||
args = append(args, os.Args[i])
|
||||
}
|
||||
}
|
||||
p, _ := filepath.Abs(os.Args[0])
|
||||
ex, _ := os.Executable()
|
||||
p, _ := filepath.Abs(ex)
|
||||
_, err := os.Stat(p)
|
||||
if !(err == nil || errors.Is(err, os.ErrExist)) {
|
||||
log.Fatalf("重置工作目录时出现错误: 无法找到路径 %v", p)
|
||||
|
@ -5,6 +5,7 @@ package server
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -28,7 +29,9 @@ func Daemon() {
|
||||
execArgs = append(execArgs, args[i])
|
||||
}
|
||||
|
||||
proc := exec.Command(os.Args[0], execArgs...)
|
||||
ex, _ := os.Executable()
|
||||
p, _ := filepath.Abs(ex)
|
||||
proc := exec.Command(p, execArgs...)
|
||||
err := proc.Start()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user