Skip to content

Commit

Permalink
feat: first
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Nov 6, 2020
1 parent 1e446cd commit 7cc372f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions glob.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package zglob

import (
"os"
"path/filepath"
"strings"

"github.com/gobwas/glob"
)

func Glob(pattern string) ([]string, error) {
var matches []string
g, err := glob.Compile(strings.TrimPrefix(pattern, "./"), '/')
if err != nil {
return matches, err
}
return matches, filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
if g.Match(path) {
matches = append(matches, path)
}
return nil
})
}
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/goreleaser/zglob

go 1.15

require github.com/gobwas/glob v0.2.3
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=

0 comments on commit 7cc372f

Please sign in to comment.