path.Match 和 filepath.Match 有什么区别?
What is the difference between path.Match and filepath.Match?
两者的文档和代码似乎相同。
为什么有两个重复的函数?
filepath
包中的一个依赖于操作系统,path
包中的一个总是使用斜杠 (/) 作为分隔符。
它们不是 "duplicates",它们是不同包的一部分,因此您应该在它们包的 上下文 中检查和解释它们。
包path
"implements utility routines for manipulating slash-separated paths"独立于平台/操作系统。
套餐path/filepath
"implements utility routines for manipulating filename paths in a way compatible with the target operating system-defined file paths".
因此,例如 path/filepath
处理操作系统之间的路径分隔符差异。
如果您仔细查看 filepath.Match()
的文档,它的结尾是:
On Windows, escaping is disabled. Instead, '\' is treated as path separator.
还有术语解释上的差异。 path.Match()
:
term:
'*' matches any sequence of non-/ characters
'?' matches any single non-/ character
和filepath.Match()
:
term:
'*' matches any sequence of non-Separator characters
'?' matches any single non-Separator character
两者的文档和代码似乎相同。 为什么有两个重复的函数?
filepath
包中的一个依赖于操作系统,path
包中的一个总是使用斜杠 (/) 作为分隔符。
它们不是 "duplicates",它们是不同包的一部分,因此您应该在它们包的 上下文 中检查和解释它们。
包path
"implements utility routines for manipulating slash-separated paths"独立于平台/操作系统。
套餐path/filepath
"implements utility routines for manipulating filename paths in a way compatible with the target operating system-defined file paths".
因此,例如 path/filepath
处理操作系统之间的路径分隔符差异。
如果您仔细查看 filepath.Match()
的文档,它的结尾是:
On Windows, escaping is disabled. Instead, '\' is treated as path separator.
还有术语解释上的差异。 path.Match()
:
term:
'*' matches any sequence of non-/ characters
'?' matches any single non-/ character
和filepath.Match()
:
term:
'*' matches any sequence of non-Separator characters
'?' matches any single non-Separator character