Skip to content

Instantly share code, notes, and snippets.

@kwmt
Created October 9, 2013 02:26
Show Gist options
  • Save kwmt/6895177 to your computer and use it in GitHub Desktop.
Save kwmt/6895177 to your computer and use it in GitHub Desktop.
リフレクションを使って関数の引数の型を出力する。
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