inject

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2017 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package inject contains code for working with Injectors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayMaker

type ArrayMaker interface {
	// Makes an array value of the given type based on the input string.
	// Returning false indicates no value was made.
	MakeArray(string, reflect.Type) (bool, reflect.Value, error)
}

type BoolMaker

type BoolMaker interface {
	// Makes a bool value based on the input string.
	// Returning false indicates no value was made.
	MakeBool(string) (bool, bool, error)
}

type ChanMaker

type ChanMaker interface {
	// Makes a chan value of the given type based on the input string.
	// Returning false indicates no value was made.
	MakeChan(string, reflect.Type) (bool, reflect.Value, error)
}

type ComplexMaker

type ComplexMaker interface {
	// Makes a complex value with the given bitSize based on the input string.
	// Returning false indicates no value was made.
	MakeComplex(s string, bitSize int) (bool, complex128, error)
}

type FloatMaker

type FloatMaker interface {
	// Makes a float value with the given bitSize based on the input string.
	// Returning false indicates no value was made.
	MakeFloat(s string, bitSize int) (bool, float64, error)
}

type FuncMaker

type FuncMaker interface {
	// Makes a func value of the given type based on the input string.
	// Returning false indicates no value was made.
	MakeFunc(string, reflect.Type) (bool, reflect.Value, error)
}

type Injector

type Injector interface {
	// May set a value based on string.
	// Returns (true, nil) when a value has been set, or (false, nil) when a value has not been set (e.g. environment
	// variable not set, file not found, etc.).
	Inject(reflect.Value, string) (bool, error)
}

An Injector sets a value based on a string.

func TypedInjector

func TypedInjector(valueMaker interface{}) Injector

TypedInjector returns an Injector utilizing valueMaker, which should implement one or more *Maker interfaces.

type InjectorFunc

type InjectorFunc func(reflect.Value, string) (bool, error)

InjectorFunc implements Injector.

func (InjectorFunc) Inject

func (f InjectorFunc) Inject(value reflect.Value, tagValue string) (bool, error)

Inject implements the Injector interface.

type IntMaker

type IntMaker interface {
	// Makes an int value with the given bitSize based on the input string.
	// Returning false indicates no value was made.
	MakeInt(s string, bitSize int) (bool, int64, error)
}

type InterfaceMaker

type InterfaceMaker interface {
	// Makes an interface value based on the input string.
	// Returning false indicates no value was made.
	MakeInterface(string) (bool, interface{}, error)
}

type MapMaker

type MapMaker interface {
	// Makes a map value based on the input string.
	// Returning false indicates no value was made.
	MakeMap(string) (bool, reflect.Value, error)
}

type PtrMaker

type PtrMaker interface {
	// Makes a pointer value based on the input string.
	// Returning false indicates no value was made.
	MakePtr(string) (bool, reflect.Value, error)
}

type SliceMaker

type SliceMaker interface {
	// Makes a slice value of the given type based on the input string.
	// Returning false indicates no value was made.
	MakeSlice(string, reflect.Type) (bool, reflect.Value, error)
}

type StringMaker

type StringMaker interface {
	// Makes a string value base on the input string.
	// Returning false indicates no value was made.
	MakeString(string) (bool, string, error)
}

type StructMaker

type StructMaker interface {
	// Makes a struct value of the given type based on the input string.
	// Returning false indicates no value was made.
	MakeStruct(string, reflect.Type) (bool, reflect.Value, error)
}

type UintMaker

type UintMaker interface {
	// Makes a uint value with the given bitSize based on the input string.
	// Returning false indicates no value was made.
	MakeUint(s string, bitSize int) (bool, uint64, error)
}

type UintPtrMaker

type UintPtrMaker interface {
	// Makes a uintptr value with the given bitSize based on the input string.
	// Returning false indicates no value was made.
	MakeUintPtr(s string, bitSize int) (bool, uintptr, error)
}

type UnsafePointerMaker

type UnsafePointerMaker interface {
	// Makes an unsafe pointer value based on the input string.
	// Returning false indicates no value was made.
	MakeUnsafePointer(string) (bool, unsafe.Pointer, error)
}

type UnsupportedKindError

type UnsupportedKindError struct {
	reflect.Kind
}

An UnsupportedKindError indicates that a value maker does not support a certain reflect.Kind.

func (*UnsupportedKindError) Error

func (e *UnsupportedKindError) Error() string

Directories

Path Synopsis
Package env provides a inject.Injector to set values from environment variables.
Package env provides a inject.Injector to set values from environment variables.
Package file provides an inject.Injector for file input.
Package file provides an inject.Injector for file input.
Package flag provides an inject.Injector to set values from command line flags.
Package flag provides an inject.Injector to set values from command line flags.
Package literal provides an inject.Injector that parses string literals into values.
Package literal provides an inject.Injector that parses string literals into values.

Jump to

Keyboard shortcuts

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