Skip to content
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 not get the method using reflect #39126

mlboy opened this issue May 18, 2020 · 2 comments

why not get the method using reflect #39126

mlboy opened this issue May 18, 2020 · 2 comments


Copy link

@mlboy mlboy commented May 18, 2020

What version of Go are you using (go version)?

$ go version go1.13.8 darwin/amd64

Does this issue reproduce with the latest release?

package main

import (

type t1 struct{}

func (t *t1) Name() string {
	return "tbl_t1"
func main() {
	m := t1{}
	rv := reflect.ValueOf(m)
	fn := rv.MethodByName("Name")
        // <invalid reflect.Value> ??????

why not get the method ?

keep 2 point :

Copy link

@D1CED D1CED commented May 18, 2020

You have to use m := &t1{}, because the method is declared on the pointer.

Copy link

@martisch martisch commented May 18, 2020

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For asking questions, see:

@martisch martisch closed this May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.