ioc

package module
v0.0.0-...-0d8e690 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	// contains filtered or unexported fields
}

func NewContainer

func NewContainer(id *ContainerTag) *Container

Creates a new instance of the Container struct with the provided ContainerTag.

id := ioc.ContainerTag("CONTAINER_ID")
ioc.NewContainer(&id)

func (*Container) Register

func (c *Container) Register(name string, dependency interface{})

Registers a dependency in the Container.

func NewYourType() *YourType {
	return &YourType{}
}

ioc.Register("NAME_OF_DEPENDENCY", NewYourType())

func (*Container) Resolve

func (c *Container) Resolve(name string) interface{}

Resolves the dependency by name.

var dependency YourType =	ioc.Resolve("NAME_OF_DEPENDENCY").(YourType)
fmt.Println(dependency.YourMethod())

type ContainerTag

type ContainerTag string

type MapIdentifier

type MapIdentifier map[*ContainerTag]*Container

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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