Created
October 9, 2013 02:26
-
-
Save kwmt/6895177 to your computer and use it in GitHub Desktop.
リフレクションを使って関数の引数の型を出力する。
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 characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
func main() { | |
f := func(n uint, m int) { | |
fmt.Println(n) | |
} | |
ft := reflect.TypeOf(f) //Type | |
// 関数fの引数1個目の型を出力 | |
fmt.Println(ft.In(0)) | |
// 関数fの引数2個目の型を出力 | |
fmt.Println(ft.In(1)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment