You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/21 17:01:53 UTC

[GitHub] [beam] lostluck commented on a diff in pull request #21943: Go SDK: Update memfs to parse the List() pattern as a glob, not a regexp

lostluck commented on code in PR #21943:
URL: https://github.com/apache/beam/pull/21943#discussion_r902860553


##########
sdks/go/pkg/beam/io/filesystem/memfs/memory.go:
##########
@@ -54,14 +55,18 @@ func (f *fs) List(_ context.Context, glob string) ([]string, error) {
 	f.mu.Lock()
 	defer f.mu.Unlock()
 
-	pattern, err := regexp.Compile(glob)
-	if err != nil {
-		return nil, err
+	globNoScheme := strings.TrimPrefix(glob, "memfs://")
+	if globNoScheme == glob {
+		return nil, fmt.Errorf("invalid pattern %q does not have prefix memfs://", glob)
 	}
 
 	var ret []string
 	for k := range f.m {
-		if pattern.MatchString(k) {
+		matched, err := path.Match(globNoScheme, strings.TrimPrefix(k, "memfs://"))

Review Comment:
   Please switch this to (path/filepath) filepath.Match instead, for consistency with the gcs and local implementations. In practice it's always linux.  Please also update the documentation in filesystem.Interface.List to be explicit as you suggested.
   
   Thank you for the contribution!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org