2

golang获取文件当前路径

 1 year ago
source link: https://studygolang.com/articles/23646?fr=sidebar
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

golang获取文件当前路径

aside section ._1OhGeD · 2019-09-27 23:33:02 · 21440 次点击 · 预计阅读时间不到 1 分钟 · 大约8小时之前 开始浏览    
这是一个创建于 2019-09-27 23:33:02 的文章,其中的信息可能已经有所发展或是发生改变。

os.Getwd()函数

原型:func Getwd()(pwd string, err error)

作用:获取当前文件路径

返回:当前文件路径的字符串和一个err信息

package main
import (
       "fmt"
       "os"
)
func main() {
       dir,_ := os.Getwd()
       fmt.Println("当前路径:",dir)
}

当前路径: D:\Projects\Go\mGoLab01


有疑问加站长微信联系(非本文作者)

280

本文来自:简书

感谢作者:aside section ._1OhGeD

查看原文:golang获取文件当前路径

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK