Skip to content

fix: build against gobwas/glob v0 and v1 - #71

Merged
tomarrell merged 1 commit into
masterfrom
fix/glob-v0-v1-compat
Oct 14, 2026
Merged

tomarrell merged 1 commit into
masterfrom
fix/glob-v0-v1-compat

Conversation

@tomarrell

Copy link
Copy Markdown
Owner

Supersedes #69. Thanks @dsymonds for raising the diamond dependency problem and for the original change.

Problem

gobwas/glob v1.0.0 keeps the v0 module path but removes the glob.Glob interface in favour of *glob.Pattern. Go selects a single version per module path, so any build that also needs glob v1 fails to compile wrapcheck.

Requiring v1 in wrapcheck, as #69 does, moves the breakage to golangci-lint. depguard v2.2.1 and protogetter v1.0.1 still use glob.Glob, so golangci-lint can't build until both cut releases.

Change

  • Store compiled globs behind an unexported globMatcher interface with a single Match(string) bool method. Both glob.Glob from v0 and *glob.Pattern from v1 satisfy it.
  • Keep go.mod at github.com/gobwas/glob v0.2.3, so wrapcheck doesn't force anything downstream onto v1.
  • Report the offending pattern in the glob compile error. It previously printed the nil compiled value and a trailing newline.
  • Run the CI tests a second time with glob v1.0.0 selected.

When a build selects glob v1, matching follows v1's semantics. Malformed patterns return an error, and example.com/**/errs no longer matches example.com/errs.

Testing

go vet ./... and go test ./... pass with glob v0.2.3 and with v1.0.0 selected via go get.

gobwas/glob v1.0.0 keeps the v0 module path but replaces the glob.Glob
interface with *glob.Pattern. Any build that selects v1 fails to compile
wrapcheck. A build selects v1 when another dependency requires it.

Store compiled globs behind an unexported globMatcher interface, which
both glob.Glob and *glob.Pattern satisfy. go.mod keeps requiring v0.2.3,
so wrapcheck doesn't force consumers such as golangci-lint onto v1 before
their other dependencies support it.

Report the offending pattern in the glob compile error instead of the
nil compiled value.

Co-authored-by: David Symonds <dsymonds@canva.com>
@tomarrell
tomarrell merged commit 14e2dd5 into master Oct 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant