Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在学习Go,不知道是不是漏掉了什么,但是搜索之后,我想知道:NodeJS中的dirname在Go中是否有等价物?如何在 Go 代码中获取当前目录,或者我必须实现一个?
在 Go 中,您可以使用os.Getwdwhich 返回与当前目录对应的根路径名。
os.Getwd
dir, err := os.Getwd() if err != nil { fmt.Errorf("Dir %v does not exists", err) }