Skip to content

proposal: path/filepath: pattern alternatives #53270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vanodevium opened this issue Jun 7, 2022 · 1 comment
Closed

proposal: path/filepath: pattern alternatives #53270

vanodevium opened this issue Jun 7, 2022 · 1 comment

Comments

@vanodevium
Copy link

It would be very cool to add the ability to use alternatives in the glob and match patterns.

Syntax of alternatives can be any:

  • (alt1|alt2|alt3)
  • (alt1,alt2,alt3)
  • {alt1|alt2|alt3}
  • {alt1,alt2,alt3}

Please look at code example:

package main

import (
	"fmt"
	"path/filepath"
)

func main() {
	fmt.Println(filepath.Match("/home/dir/*.(txt,pdf)", "/home/dir/resume.txt"))
	fmt.Println(filepath.Match("/home/dir/*.(txt,pdf)", "/home/dir/resume.png"))
}

Output:

true <nil>
false <nil>

I apologize if I'm suggesting something that has already been suggested. As it seemed to me, I looked for references, but did not find.

@gopherbot gopherbot added this to the Proposal milestone Jun 7, 2022
@seankhliao
Copy link
Member

Duplicate of #32745

@seankhliao seankhliao marked this as a duplicate of #32745 Jun 7, 2022
@golang golang locked and limited conversation to collaborators Jun 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants