加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

golang1.1 path包bug

发布时间:2020-12-16 18:59:23 所属栏目:大数据 来源:网络整理
导读:func Dir(path string) string Dir returns all but the last element of path,typically the path's directory. After dropping the final element using Split,the path is Cleaned and trailing slashes are removed. If the path is empty,Dir returns "
func Dir(path string) string

Dir returns all but the last element of path,typically the path's directory. After dropping the final element using Split,the path is Cleaned and trailing slashes are removed. If the path is empty,Dir returns ".". If the path consists entirely of slashes followed by non-slash bytes,Dir returns a single slash. In any other case,the returned path does not end in a slash.

?示例

代码:

fmt.Println(path.Dir("/a/b/c"))

输出:

/a/b
这个函数属于path package中的一个,但是无法解析windows的反斜杠地址,比如:输入:
fmt.Println(path.Dir("c:macsleo"))
输出为:.
一个dot号。
但是golang牛逼的地方在于:可以解析这样的地址:C:golangsrcLBSIM-MVC2src/conf/config.json,,哈哈 真是好用,不需要 我自己调用runtime.GOOS进行判断了。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读