refactor: drop dependency on github.com/fatih/structtag#1650
Open
alexandear wants to merge 7 commits intomgechev:masterfrom
Open
refactor: drop dependency on github.com/fatih/structtag#1650alexandear wants to merge 7 commits intomgechev:masterfrom
alexandear wants to merge 7 commits intomgechev:masterfrom
Conversation
beda91b to
f8fe9b6
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the dependency on github.com/fatih/structtag by introducing an internal internal/structtag package that implements the needed struct-tag parsing functionality, and updates the struct-tag rule to use it.
Changes:
- Added
internal/structtagwith aParsefunction andTaghelpers (Value,String). - Updated
rule/struct_tag.goto use the new internal parser. - Removed
github.com/fatih/structtagfromgo.mod/go.sumand added tests for the new parser.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| rule/struct_tag.go | Switches the struct-tag rule to the new internal parser API. |
| internal/structtag/structtag.go | New internal struct tag parser and Tag implementation. |
| internal/structtag/structtag_test.go | New unit tests validating parsing and Tag.Value(). |
| go.mod | Drops the github.com/fatih/structtag dependency. |
| go.sum | Removes checksums for the dropped dependency. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
denisvmedia
reviewed
Feb 24, 2026
denisvmedia
reviewed
Feb 24, 2026
denisvmedia
approved these changes
Feb 24, 2026
Collaborator
denisvmedia
left a comment
There was a problem hiding this comment.
LGTM, with a couple of nit comments
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.
This PR drops one dependency.
Because https://github.com/fatih/structtag seems unmaintained, and we do not utilize all the functions from the library. We need only
Parse.Our implementation is a little bit faster:
bench_test.go
Inspired by https://cs.opensource.google/go/x/tools/+/refs/tags/v0.42.0:go/analysis/passes/structtag/structtag.go