vary

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 1 Imported by: 2

README

Overview

A simple lib to reflect the implementations of interfaces.

Read the test for usage.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = NewInterfaces()

Default is the default registry.

Functions

This section is empty.

Types

type Interface

type Interface struct {
	Self            reflect.Type
	Implementations map[TypeID]reflect.Type
}

func Get

func Get(id TypeID) *Interface

Get interface from the Default.

func New

func New(v interface{}, vs ...interface{}) *Interface

New interface on the Default.

func (*Interface) Add

func (i *Interface) Add(v interface{}) struct{}

func (*Interface) Has

func (i *Interface) Has(v interface{}) bool

Has returns true if the v has bind to i.

func (*Interface) ID

func (i *Interface) ID() TypeID

type Interfaces

type Interfaces map[TypeID]*Interface

func NewInterfaces

func NewInterfaces() Interfaces

NewInterfaces registry.

func (Interfaces) New

func (r Interfaces) New(v interface{}, vs ...interface{}) *Interface

New interface.

type TypeID

type TypeID string

TypeID is a unique identifier for a type.

func ID

func ID(t reflect.Type) TypeID

ID for the type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL