go项目脚手架
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.
sorbet/pkg/ioc/util.go

20 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
}