aboutsummaryrefslogtreecommitdiffstats
path: root/glob.go
diff options
context:
space:
mode:
Diffstat (limited to 'glob.go')
-rw-r--r--glob.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/glob.go b/glob.go
index 4f7e978..6a3fd58 100644
--- a/glob.go
+++ b/glob.go
@@ -57,7 +57,8 @@ func (c *Context) glob(pattern string, excludes []string) ([]string, error) {
if exists {
// Glob has already been done, double check it is identical
verifyGlob(fileName, pattern, excludes, g)
- return g.Files, nil
+ // Return a copy so that modifications don't affect the cached value.
+ return append([]string(nil), g.Files...), nil
}
// Get a globbed file list
@@ -76,10 +77,12 @@ func (c *Context) glob(pattern string, excludes []string) ([]string, error) {
// Getting the list raced with another goroutine, throw away the results and use theirs
if exists {
verifyGlob(fileName, pattern, excludes, g)
- return g.Files, nil
+ // Return a copy so that modifications don't affect the cached value.
+ return append([]string(nil), g.Files...), nil
}
- return files, nil
+ // Return a copy so that modifications don't affect the cached value.
+ return append([]string(nil), files...), nil
}
func (c *Context) Globs() []GlobPath {