inject

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(name, tag string) (found bool, value string, err error)

Extract the quoted value for the given name returning it if it is found. The found boolean helps differentiate between the "empty and found" vs "empty and not found" nature of default empty strings.

func Populate

func Populate(values ...interface{}) error

Populate is a short-hand for populating a Container with the given incomplete object values.

Types

type Container

type Container struct {
	Logger Logger // Optional, will trigger debug logging.
	// contains filtered or unexported fields
}

The Container of Objects.

func (*Container) Objects

func (g *Container) Objects() []*Object

Objects returns all known objects, named as well as unnamed. The returned elements are not in a stable order.

func (*Container) Populate

func (g *Container) Populate() error

Populate the incomplete Objects.

func (*Container) PopulateTarget

func (g *Container) PopulateTarget(dst interface{}) error

func (*Container) Provide

func (g *Container) Provide(objects ...*Object) error

Provide objects to the Container. The Object documentation describes the impact of various fields.

func (*Container) Resolve

func (g *Container) Resolve(dst interface{}) error

Resolve sets the value of dst to an assignable instance

func (*Container) ResolveByName

func (g *Container) ResolveByName(dst interface{}, name string) error

ResolveByName sets the value of dst to an assignable instance with the provided name

type Logger

type Logger interface {
	Debugf(format string, v ...interface{})
}

Logger allows for simple logging as inject traverses and populates the object Container.

type Object

type Object struct {
	Value    interface{}
	Name     string             // Optional
	Complete bool               // If true, the Value will be considered complete
	Fields   map[string]*Object // Populated with the field names that were injected and their corresponding *Object.
	// contains filtered or unexported fields
}

An Object in the Container.

func (*Object) String

func (o *Object) String() string

String representation suitable for human consumption.

Jump to

Keyboard shortcuts

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