func extensionTypes(extension interface{}) []string {
	var ifaces []string
	typ := reflect.TypeOf(extension)
	for name, ep := range extRegistry.m {
		if ep.iface.Kind() == reflect.Func && typ.AssignableTo(ep.iface) {
			ifaces = append(ifaces, name)
		}
		if ep.iface.Kind() != reflect.Func && typ.Implements(ep.iface) {
			ifaces = append(ifaces, name)
		}
	}
	return ifaces
}
Top level registration
package plugin
import (
	"reflect"
	"runtime"
	"strings"
	"sync"
)
var extRegistry = &registryType{m: make(map[string]*extensionPoint)}
type registryType struct {
	sync.Mutex
	m map[string]*extensionPoint
}