-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix!: Pass url struct tags by value instead of by reference
#3991
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3991 +/- ##
=======================================
Coverage 93.52% 93.52%
=======================================
Files 207 207
Lines 17593 17593
=======================================
Hits 16454 16454
Misses 938 938
Partials 201 201 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
|
If any of you have time to review, that would be greatly appreciated. cc: @stevehipwell - @alexandear - @zyfy29 - @Not-Dhananjay-Mishra |
| switch ident.Name { | ||
| // Remove the pointer for primitives in url tags | ||
| case "string", "int", "int64", "float64", "bool": | ||
| return ident.Name, false |
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.
Can we use isBuiltinType helper function?
| switch ident.Name { | |
| // Remove the pointer for primitives in url tags | |
| case "string", "int", "int64", "float64", "bool": | |
| return ident.Name, false | |
| // Remove the pointer for primitives in url tags | |
| if isBuiltinType(ident.Name){ | |
| return ident.Name, false |
|
Also, should we update all the struct in this PR? I believe a lot of struct need to be change |
BREAKING CHANGE: Many
*Optionsstructs now passomitemptyURL struct fields by value instead of by reference.Fixes: #3990.
Relates to: #3984.
Over time, I had allowed and even encouraged pointers to primitive types to be used in the URL struct tags when "omitempty" was provided. This violates the spirit of the purpose of the use of pointers for GitHub resource types as declared in this repo's README.md, and this is the first step to getting back on track to a self-consistent client library.
I apologize for the breakages that this PR causes and for all the contributors whom I wrongly steered during code reviews.
Note that timestamps can still be passed by reference (or by value if using
omitzero).Also note that a new
check-structfield-settingstool is added to this repo that will report (and optionally-fix) any obsolete exceptions listed in the.golangci.ymlfile at the root of the repo.