golang1.1 path包bug

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:\macs\leo\"))
输出为:.
一个dot号。
但是golang牛逼的地方在于:可以解析这样的地址:C:\golang\src\LBSIM-MVC2\src/conf/config.json,,哈哈 真是好用,不需要 我自己调用runtime.GOOS进行判断了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值