path/filepath 基本使用

本文介绍了Go语言标准库path/filepath中用于处理文件路径的各种函数,包括判断绝对路径、获取相对路径、路径分割、连接、转换及遍历等操作。详细讲解了如`Abs()`, `Rel()`, `Split()`, `Join()`, `Clean()`, `Match()`, `Glob()`和`Walk()`等方法的使用,并提供了示例代码。" 41480427,878406,推荐系统实践:初学者的全面指南,"['推荐系统', '数据挖掘', '机器学习', '算法', '数据处理']
摘要由CSDN通过智能技术生成

标准库path/filepath中提供了对各个操作系统文件路径的操作函数,一般情况下不要使用path,因为package path 只兼容以/为路径分隔符的系统

方法使用

func IsAbs(path string) bool

该函数以路径为参数,如果该路径为绝对路径,那么返回true,如果不是返回false

func Abs(path string) (string, error)

// Abs returns an absolute representation of path.
// If the path is not absolute it will be joined with the current
// working directory to turn it into an absolute path. The absolute
// path name for a given file is not guaranteed to be unique.
// Abs calls Clean on the result.
func Abs(path string) (string, error) {
   
	return abs(path)
}

func unixAbs(path string) 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值