如何编写demo.go打印安装路径的程序demo.exe?
D:\>go build demo.go
demo.exe在D:\. 移动demo.exe到后C:\Windows,然后在D:\路径下(它不在C:\Windows)运行demo.exe应该打印C:\Windows。
下图显示的不是这种情况下的工作(因为 demo.exe 总是得到它当前的执行路径,而不是它的真正路径)。这只是告诉您当前的执行目录,而不是包含文件 https://github.com/axgle/go/blob/master/may_app_path_bug.jpg的目录
更新:window/linux 解决方案在这里 https://github.com/axgle/app