import{

"os/exec"
"path/filepath"

}


//文件完整路径

filePath, _ := exec.LookPath(os.Args[0])

//文件相对路径
dirPath := filepath.Dir(osPath) 


//文件名

fileName := filepath.Base(osPath)

转载于:https://my.oschina.net/koalaone/blog/214383