You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

glob.go 658B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2024 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package setting
  4. import "github.com/gobwas/glob"
  5. type GlobMatcher struct {
  6. compiledGlob glob.Glob
  7. patternString string
  8. }
  9. var _ glob.Glob = (*GlobMatcher)(nil)
  10. func (g *GlobMatcher) Match(s string) bool {
  11. return g.compiledGlob.Match(s)
  12. }
  13. func (g *GlobMatcher) PatternString() string {
  14. return g.patternString
  15. }
  16. func GlobMatcherCompile(pattern string, separators ...rune) (*GlobMatcher, error) {
  17. g, err := glob.Compile(pattern, separators...)
  18. if err != nil {
  19. return nil, err
  20. }
  21. return &GlobMatcher{
  22. compiledGlob: g,
  23. patternString: pattern,
  24. }, nil
  25. }