Created
August 31, 2016 05:58
-
-
Save legendtkl/f737f75a407d9e4f1312ef02cd15919d to your computer and use it in GitHub Desktop.
Revisions
-
legendtkl created this gist
Aug 31, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ package main import ( "reflect" "fmt" ) type Test struct { fn interface{} args []reflect.Value } func foo(t Test) { reflect.ValueOf(t.fn).Call(t.args) } func bar(i, j int) { fmt.Println(i+j) } func main() { f := bar x, y := 3, 5 arg := []reflect.Value{reflect.ValueOf(x), reflect.ValueOf(y)} test := Test{ fn: f, args: arg, } foo(test) }