Skip to content

Commit

Permalink
pkg/tool/file: Replace filepath.Glob with doublestar.FilepathGlob
Browse files Browse the repository at this point in the history
The Go stdlib implements Glob with Match as its base and does not support the double star syntax. To allow recursive lists via file.Glob it should be supported.

Signed-off-by: Fionera <fionera@fionera.de>
  • Loading branch information
fionera committed Sep 13, 2022
1 parent 9e9786e commit 55ed05c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module cuelang.org/go
go 1.17

require (
github.com/bmatcuk/doublestar/v4 v4.2.0
github.com/cockroachdb/apd/v2 v2.0.2
github.com/emicklei/proto v1.10.0
github.com/google/go-cmp v0.5.8
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/bmatcuk/doublestar/v4 v4.2.0 h1:Qu+u9wR3Vd89LnlLMHvnZ5coJMWKQamqdz9/p5GNthA=
github.com/bmatcuk/doublestar/v4 v4.2.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E=
github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
Expand Down
5 changes: 4 additions & 1 deletion pkg/tool/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"cuelang.org/go/cue"
"cuelang.org/go/cue/errors"
"cuelang.org/go/internal/task"

"github.com/bmatcuk/doublestar/v4"
)

func init() {
Expand Down Expand Up @@ -114,7 +116,8 @@ func (c *cmdGlob) Run(ctx *task.Context) (res interface{}, err error) {
if ctx.Err != nil {
return nil, ctx.Err
}
m, err := filepath.Glob(glob)

m, err := doublestar.FilepathGlob(glob)
for i, s := range m {
m[i] = filepath.ToSlash(s)
}
Expand Down

0 comments on commit 55ed05c

Please sign in to comment.