获取运行程序的所在目录、工作目录
import ( "fmt" "os" "path/filepath" ) func main() { fmt.Println("start m1") path, _ := os.Executable() fmt.Println("path", filepath.Dir(path)) dir, _ := filepath.Abs(filepath.Dir(os.Args[0])) fmt.Println("os.Args", dir) dir, _ = os.Getwd() fmt.Println("Getwd", dir) dir, _ = filepath.Abs("./") fmt.Println("./", dir) }标签:读取,filepath,fmt,golang,Println,os,目录,dir From: https://www.cnblogs.com/htsky/p/17644431.html
/*
start m1
path D:\Workspaces\golang-demo23\mt76
os.Args D:\Workspaces\golang-demo23\mt76
Getwd D:\Workspaces\golang-demo23\mt76
./ D:\Workspaces\golang-demo23\mt76
*/