injects

package
v0.3.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Service = NewInjects()

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 NewInjects

func NewInjects() *global

func Populate

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

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

Types

type Config

type Config struct {
	Name string // name
	Step Step   // step 越小,执行越靠前
}

type Graph

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

The Graph of Objects.

func (*Graph) Objects

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

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

func (*Graph) Populate

func (g *Graph) Populate() error

Populate the incomplete Objects.

func (*Graph) Provide

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

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

type Logger

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

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

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.

	Path string
	// contains filtered or unexported fields
}

An Object in the Graph.

func (*Object) String

func (o *Object) String() string

String representation suitable for human consumption.

type Step

type Step int8

Jump to

Keyboard shortcuts

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