registry

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlwaysReturn added in v0.2.0

func AlwaysReturn[T any](v T) func(name string) T

AlwaysReturn the given value, it's an implementation of unregisterReturn

Types

type Registry

type Registry[T any] struct {
	// contains filtered or unexported fields
}

Registry provider Register and Get zero value is not ready for use, New it

this is a map, but - can't Register a name twice, panic if it happens - can get a hook on Get an unregistered name

after go support generics type, it seems not need to use this package.

func New

func New[T any](
	name string,
	unregisterReturn func(name string) T,
) *Registry[T]

func (*Registry[T]) Get

func (r *Registry[T]) Get(name string) T

func (*Registry[T]) Register

func (r *Registry[T]) Register(name string, item T)

Register item

Jump to

Keyboard shortcuts

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