pull/79/head^2
zhangchenhao 2025-05-12 11:23:04 +08:00
parent 6462eaf9d3
commit ec3a709524
1 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,12 @@ import (
) )
func init() { func init() {
dir, err := os.Getwd()
if err != nil {
fmt.Println("获取工作目录失败:", err)
return
}
fmt.Println("当前运行目录是:", dir)
// 指定运行目录为当前目录 // 指定运行目录为当前目录
exePath, err := os.Executable() exePath, err := os.Executable()
if err != nil { if err != nil {
@ -34,7 +40,7 @@ func init() {
os.Exit(1) os.Exit(1)
} }
dir, err := os.Getwd() dir, err = os.Getwd()
if err != nil { if err != nil {
fmt.Println("获取工作目录失败:", err) fmt.Println("获取工作目录失败:", err)
return return