Skip to content

Add MatchBytes() #32

Description

@willbuckner

Adding a MatchBytes() to match a glob pattern against a byte slice would be incredibly useful for searching within files.

For example:

package main

import "github.com/gobwas/glob"

func main() {
    var g glob.Glob
    
    g = glob.MustCompile("*.github.com")
    g.MatchBytes([]byte("api.github.com")) // true
}

A further justification of this is how the regex package operates on bytes by default. I am not suggesting modifying the default behavior, though, but adding a MatchString() alias could help maintain compatibility if it ever becomes the default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions