我在尝试理解 filepath.Glob 时遇到了这一点
for _, v := range ListofPaths{
exists, _ := filepath.Glob(fmt.Sprintf("%s/*/%s", v, filename))
}
适用于任何路径
ListofPathsPath/any/dot/thing/filename.ext
但不是
ListofPathsPath/filename.ext
所以从上面我需要匹配 glob %s/%s 或 %s/*/%s
有没有办法表达这个?我还没有完全理解 filepath.Match 语法,也没有找到任何全面的示例。
最佳答案
这确实是基本的 shell 语法,你不能这样做。
您必须调用 glob 两次或仅使用 filepath.Walk
.
关于regex - 在 Go 中使用 filepath.Glob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25164070/