...
1# filepathx
2
3> A small `filepath` extension library that supports double star globbling.
4
5## Documentation
6
7GoDoc: <https://pkg.go.dev/github.com/yargevad/filepathx>
8
9## Install
10
11```bash
12go get github.com/yargevad/filepathx
13```
14
15## Usage Example
16
17You can use `a/**/*.*` to match everything under the `a` directory
18that contains a dot, like so:
19
20```go
21package main
22
23import (
24 "fmt"
25 "os"
26
27 "github.com/yargevad/filepathx"
28)
29
30func main() {
31 if 2 != len(os.Args) {
32 fmt.Println(len(os.Args), os.Args)
33 fmt.Fprintf(os.Stderr, "Usage: go build example/find/*.go; ./find <pattern>\n")
34 os.Exit(1)
35 return
36 }
37 pattern := os.Args[1]
38
39 matches, err := filepathx.Glob(pattern)
40 if err != nil {
41 panic(err)
42 }
43
44 for _, match := range matches {
45 fmt.Printf("MATCH: [%v]\n", match)
46 }
47}
48```
49
50Given this directory structure:
51
52```bash
53find a
54```
55
56```txt
57a
58a/b
59a/b/c.d
60a/b/c.d/e.f
61```
62
63This will be the output:
64
65```bash
66go build example/find/*.go
67./find 'a/**/*.*'
68```
69
70```txt
71MATCH: [a/b/c.d]
72MATCH: [a/b/c.d/e.f]
73```
View as plain text