[Go] go run 时 os.Getwd 和 os.Executable 获取程序根路径

os.Getwd返回的是当前路径

 os.Executable返回的是临时文件的绝对路径

package tools

import (
    "log"
    "os"
    "testing"
)

func TestOs(t *testing.T) {
    log.Println(os.Getwd())
    log.Println(os.Executable())
}

 

 

 

 

posted @ 2021-09-28 10:16  唯一客服系统开发笔记  阅读(412)  评论(0编辑  收藏  举报