-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Why are all the responses using pointers #1429
Comments
I get the nil checking, what I don't understand is why to apply this on I Would do something like this. That simplifies codebase and consumption of it a lot. type SomeType struct {
MyOtherObject *OtherType
Amount Int64
Text string
Collection []CollectionItem
} An empty string can then be treated the same as nil and 0 can also be treated similar. No more nil checks there. And I think in the case of slices it doesn't add value as well. Either there is an element in the slice or it is not. Why would you want to have nil elements in the slice? Only the case were another struct like MyOtherObject is used I could think of user a pointer. Am I completely missing out on something? |
This has been discussed at length... (whups, I forgot to include others like #537), but here are short answers:
|
Thanks for explaining. |
I noticed most responses are using slices of pointers. IMHO it would be better to not use pointers in the slices.
Also I don't think we should use pointers for strings in the JSON.
It will reduce the amount of required null checks, simplify working with the strings. Furthermore a slice is already kind of using pointers.
Is there any reason for this?
Would a PR removing the pointers in those locations be accepted?
The text was updated successfully, but these errors were encountered: