2017-07-13 7 views

答えて

1

これを試してみてください:

t := reflect.TypeOf((*FooService)(nil)).Elem() 
var s []string 
for i := 0; i < t.NumMethod(); i++ { 
    s = append(s, t.Method(i).Name) 
} 

playground example

インターフェイスタイプのreflect.Typeを取得するには、トリッキーな部分です。説明はHow to get the reflect.Type of an interface?を参照してください。

関連する問題