-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
reflect: add StructField.IsExported and Method.IsExported #41563
Comments
Minor side note: the field name |
I'm OK with adding IsExported() bool. |
Based on the discussion above, this seems like a likely accept. |
I should note that we probably want to add an |
SGTM |
That change to NumMethod is likely to be rolled back. |
No change in consensus, so accepted. |
Change https://golang.org/cl/266197 mentions this issue: |
The
StructField.PkgPath
field is populated if and only if the field is unexported. However, there is a hit to readability:It's not obvious to most readers why the
f.PkgPath != ""
check exist. For this reason, a vast majority of cases have a comment that says:This documentation seems unnecessary if we had just added a helper method on
StructField
like:Thus, use of it becomes obvious from a readability perspective:
Bikeshedding: I don't have a preference whether this should be called
IsExported
or simplyExported
. The former matchesIsValid
,IsNil
, orIsZero
, while the latter matchesStructField.Anonymous
. It seems that thereflect
package is already internally inconsistent about naming of predicate functionality.The text was updated successfully, but these errors were encountered: