[英]Finding the current working directory programmatically in go?
I have been looking trough the go documentation but so far I haven't found anything. 我一直在寻找go go文档,但到目前为止我还没有找到任何东西。 I need help to find the
current working directory
programmaticly in go language. 我需要帮助以go语言编程方式查找
current working directory
。 Does any one know how to do that? 有谁知道这是怎么做到的吗?
Getwd from the os package will return your current working directory. 来自os包的Getwd将返回当前的工作目录。 For more operating system related functions look in the
os
package. 有关更多与操作系统相关的功能,请查看
os
包。
If you want to print it do the following. 如果要打印,请执行以下操作。
import (
"fmt"
"os"
)
func main() {
wd, _ := os.Getwd()
fmt.Println("Working Directory:", wd)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.