factory

package module
v0.0.0-...-4fac4ec Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

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

func New

func New[T any](dummy T) Factory[T]

New creates a factory which stores and instantiates objects of the specified interface type. A "dummy" version needs to be passed to avoid Go's error checking mechanism from being triggered.

func (*Factory[T]) Instantiate

func (fac *Factory[T]) Instantiate(name string) (T, error)

Instantiate is a factory function which instantiates an instance of an object with autodiscovery.

func (*Factory[T]) Register

func (fac *Factory[T]) Register(name string, f func() T)

Register registers a new object for instantiation.

Jump to

Keyboard shortcuts

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