Repository navigation
fix: build against gobwas/glob v0 and v1 - #71
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Globinterface 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
globMatcherinterface with a singleMatch(string) boolmethod. Bothglob.Globfrom v0 and*glob.Patternfrom v1 satisfy it.go.modatgithub.com/gobwas/glob v0.2.3, so wrapcheck doesn't force anything downstream onto v1.When a build selects glob v1, matching follows v1's semantics. Malformed patterns return an error, and
example.com/**/errsno longer matchesexample.com/errs.Testing
go vet ./...andgo test ./...pass with glob v0.2.3 and with v1.0.0 selected viago get.