Documentation
¶
Overview ¶
Package pathx 提供文件路径匹配工具。
MatchesPath 支持标准 glob 模式和 /** 目录前缀匹配, 适用于 .gitignore 风格的路径过滤场景(代码审查忽略路径、构建排除等)。
用法:
pathx.MatchesPath([]string{"vendor/**", "*.test"}, "vendor/foo/bar.go") // true
pathx.MatchesPath([]string{"*.go"}, "main.go") // true
Package pathx 提供文件路径匹配工具。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchesPath ¶
MatchesPath 检查路径是否匹配任意一个 glob 模式。 支持标准 filepath.Match 模式以及 /** 目录前缀匹配。
模式示例:
- "*.go" → 匹配根目录下的 .go 文件
- "vendor/*" → 匹配 vendor 目录下的直接子项
- "node_modules/**" → 匹配 node_modules 下所有层级的文件
- "test/*.txt" → 匹配 test 目录下的 .txt 文件
用法:
pathx.MatchesPath([]string{"vendor/**", "*.test"}, "vendor/foo/bar.go") // true
pathx.MatchesPath([]string{"*.go"}, "main.go") // true
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.