douzhi2760 2016-12-21 03:07
浏览 1280
已采纳

如何在Google Golang中获取Windows的系统根目录?

Under Windows, the system root directory could be like C:// or D:// (when the OS is installed in driver D:/). How to get this folder in Go?

  • 写回答

2条回答 默认 最新

  • doubi4340 2016-12-21 03:46
    关注

    You could use filepath.VolumeName(os.GetEnv("SYSTEMROOT")) + "\\" or the shorter os.GetEnv("SYSTEMDRIVE") + "\\". The windir environment variable probably shouldn't be used anymore honestly since it is not a system-controlled environment variable.

    Source for the mentioned environment variables

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?