Skip to content

Add MatchBytes() #32

Open
Open

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.

Activity

  1. gobwas commented on Aug 17, 2026

    @gobwas
    Owner

    Still makes sense after #73; the engine works on strings internally, so this needs either an unsafe view or a bytes path. Keeping open for v1.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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