We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Consider the following:
type iface interface { private() Public() } t := reflect.TypeOf((*iface)(nil)).Elem() for i := 0; i < t.NumMethod(); i++ { fmt.Println(t.Method(i)) }
This currently prints:
{Public func() <invalid Value> 0} {private main func() <invalid Value> 1}
The documented behavior of reflect.Type.NumMethod is:
reflect.Type.NumMethod
NumMethod returns the number of exported methods in the value's method set.
However, you can clearly see that private is included as part of the count.
private
It seems to me that for reflect.Interface, the NumMethod does include unexported methods, while it excludes them for all other kinds.
reflect.Interface
NumMethod
The text was updated successfully, but these errors were encountered:
This is #22075.
Sorry, something went wrong.
Duplicate indeed. Thank you.
No branches or pull requests
Consider the following:
This currently prints:
The documented behavior of
reflect.Type.NumMethod
is:However, you can clearly see that
private
is included as part of the count.It seems to me that for
reflect.Interface
, theNumMethod
does include unexported methods, while it excludes them for all other kinds.The text was updated successfully, but these errors were encountered: