Go语言:判断一个路径是不是绝对路径
2019-11-17 本文已影响0人
白祤星
代码实例:
package main
import "path/filepath"
func main() {
// 判断路径是不是绝对路径
isPath := filepath.IsAbs(`C:\Windows\explorer.exe`)
println(isPath)
// 错误的例子-1
isPath = filepath.IsAbs(`./a/b/c`)
println(isPath)
// 错误的例子-2
isPath = filepath.IsAbs(`/a/b/c`)
println(isPath)
}