-
Notifications
You must be signed in to change notification settings - Fork 312
struct-tag: change reported messages and refactor implementation #1292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…coherence in failures msg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit worried by this filename
It relies on build tag
It's OK, but then as soon as Go 1.25 will be out, this file won't be used, and the structtag_test.go will, so it will fail.
Unless I'm misunderstanding the concept of how build tags works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it. The PR doesn't modify the filename and the filename follows the convention of testdata files in revive: <rule_name>(_other_details)?.go
BTW: there is also testdata/struct_tag.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is made from multiple considerations
- go.mod fixes the minimal version to 1.23
- testdata/go1.24/struct_tag.go is there for the go 1.24 version
- testdata/struct_tag.go is here for any other versions, so right now for go 1.23 only
But when I commented yesterday I thought the file was something like struct_tag_go124_test.go so using build tag while it doesn't.
So my suggestion was unclear, because I was wrong.
But while my suggestion was wrong, the considerations are still there.
When Go 1.25 will go out, the tests will call testdata/struct_tag.go, right?
And omitzero will still be supported.
You may argue the minimal version would be bumped when Go 1.25 will be out, but I think current code could cause issues.
So here is my suggestion
- rename testdata/struct_tag.go to testdata/go1.23/struct_tag.go
- rename testdata/go1.24/struct_tag.go to testdata/struct_tag.go
This way there will be no problem with Go 1.25
I hope it would be clearer, but maybe I'm overthinking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Go 1.25 will go out, the tests will call testdata/struct_tag.go, right?
When Go 1.25 will go out, the tests will call all tests from test/struct_tag_test.go:
- testdata/struct_tag.go
- testdata/struct_tag_user_options.go
- testdata/go1.24/struct_tag.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is made from multiple considerations
- go.mod fixes the minimal version to 1.23
- testdata/go1.24/struct_tag.go is there for the go 1.24 version
- testdata/struct_tag.go is here for any other versions, so right now for go 1.23 only
But when I commented yesterday I thought the file was something like struct_tag_go124_test.go so using build tag while it doesn't.
So my suggestion was unclear, because I was wrong.
But while my suggestion was wrong, the considerations are still there.
When Go 1.25 will go out, the tests will call testdata/struct_tag.go, right?
And omitzero will still be supported.
You may argue the minimal version would be bumped when Go 1.25 will be out, but I think current code could cause issues.
So here is my suggestion
- rename testdata/struct_tag.go to testdata/go1.23/struct_tag.go
- rename testdata/go1.24/struct_tag.go to testdata/struct_tag.go
This way there will be no problem with Go 1.25
I hope it would be clearer, but maybe I'm overthinking
This PR proposes a ~full rewriting of the rule
struct-tagin an attempt to clean-up the implementation.This PR introduces the following changes: