You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
404 B
19 lines
404 B
package ioc
|
|
|
|
import "reflect"
|
|
|
|
// InterfaceOf dereferences a pointer to an Interface type.
|
|
// It panics if value is not a pointer to an interface.
|
|
func InterfaceOf(value interface{}) reflect.Type {
|
|
t := reflect.TypeOf(value)
|
|
|
|
for t.Kind() == reflect.Ptr {
|
|
t = t.Elem()
|
|
}
|
|
|
|
if t.Kind() != reflect.Interface {
|
|
panic("the value is not a pointer to an interface. (*MyInterface)(nil)")
|
|
}
|
|
|
|
return t
|
|
}
|
|
|