Created
May 6, 2021 06:54
-
-
Save chrisvdg/3780e037a4aee654070bb356226e96c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
type My struct{} | |
func (m My) MyFunc(name string) { | |
fmt.Printf("MyFunc called %s\n", name) | |
} | |
func main() { | |
m := My{} | |
meth := reflect.ValueOf(m).MethodByName("MyFunc") | |
in := make([]reflect.Value, 1) | |
in[0] = reflect.ValueOf("hello") | |
meth.Call(in) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment