Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Dependency injection for go

License

NotificationsYou must be signed in to change notification settings

codegangsta/inject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

--import "github.com/codegangsta/inject"

Package inject provides utilities for mapping and injecting dependencies invarious ways.

Language Translations:

Usage

func InterfaceOf

funcInterfaceOf(valueinterface{}) reflect.Type

InterfaceOf dereferences a pointer to an Interface type. It panics if value isnot an pointer to an interface.

type Applicator

typeApplicatorinterface {// Maps dependencies in the Type map to each field in the struct// that is tagged with 'inject'. Returns an error if the injection// fails.Apply(interface{})error}

Applicator represents an interface for mapping dependencies to a struct.

type Injector

typeInjectorinterface {ApplicatorInvokerTypeMapper// SetParent sets the parent of the injector. If the injector cannot find a// dependency in its Type map it will check its parent before returning an// error.SetParent(Injector)}

Injector represents an interface for mapping and injecting dependencies intostructs and function arguments.

func New

funcNew()Injector

New returns a new Injector.

type Invoker

typeInvokerinterface {// Invoke attempts to call the interface{} provided as a function,// providing dependencies for function arguments based on Type. Returns// a slice of reflect.Value representing the returned values of the function.// Returns an error if the injection fails.Invoke(interface{}) ([]reflect.Value,error)}

Invoker represents an interface for calling functions via reflection.

type TypeMapper

typeTypeMapperinterface {// Maps the interface{} value based on its immediate type from reflect.TypeOf.Map(interface{})TypeMapper// Maps the interface{} value based on the pointer of an Interface provided.// This is really only useful for mapping a value as an interface, as interfaces// cannot at this time be referenced directly without a pointer.MapTo(interface{},interface{})TypeMapper// Provides a possibility to directly insert a mapping based on type and value.// This makes it possible to directly map type arguments not possible to instantiate// with reflect like unidirectional channels.Set(reflect.Type, reflect.Value)TypeMapper// Returns the Value that is mapped to the current type. Returns a zeroed Value if// the Type has not been mapped.Get(reflect.Type) reflect.Value}

TypeMapper represents an interface for mapping interface{} values based on type.

About

Dependency injection for go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp