compiler

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidConstructor is error triggered when constructor have invalid signature.
	ErrInvalidConstructor = errors.New("unexpected constructor")
)
View Source
var (

	// ErrInvalidType is error triggered when provided invalid type.
	ErrInvalidType = errors.New("invalid type")
)
View Source
var (

	// ErrInvalidValue is error triggered when provided invalid value.
	ErrInvalidValue = errors.New("invalid value")
)
View Source
var ErrPanicked = errors.New("panicked")

Functions

This section is empty.

Types

type Closer

type Closer = func() error

type Compiler

type Compiler interface {
	Create(dependencies ...*Dependency) (reflect.Value, Closer, error)
	Dependencies() []*Dependency
	Type() reflect.Type
}

type Constructor

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

Constructor implements the Compiler interface.

func NewConstructor

func NewConstructor(fn any) (*Constructor, error)

NewConstructor is constructor of Constructor. Argument fn may be one of:

  • func New(args ...any) (value any)
  • func New(args ...any) (value any, err error)
  • func New(args ...any) (value any, closer func(){})
  • func New(args ...any) (value any, closer func(){}, err error)

func (*Constructor) Create

func (c *Constructor) Create(dependencies ...*Dependency) (_ reflect.Value, _ Closer, err error)

func (*Constructor) Dependencies

func (c *Constructor) Dependencies() []*Dependency

func (*Constructor) Type

func (c *Constructor) Type() reflect.Type

type Dependency

type Dependency struct {
	Name  string
	Index int
	Type  reflect.Type
	Value reflect.Value
}

type Type

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

func NewType

func NewType(v any) (*Type, error)

func (*Type) Create

func (c *Type) Create(deps ...*Dependency) (reflect.Value, Closer, error)

func (*Type) Dependencies

func (c *Type) Dependencies() []*Dependency

func (*Type) Type

func (c *Type) Type() reflect.Type

type Value

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

func NewValue

func NewValue(v any) (*Value, error)

func (*Value) Create

func (c *Value) Create(_ ...*Dependency) (reflect.Value, Closer, error)

func (*Value) Dependencies

func (c *Value) Dependencies() []*Dependency

func (*Value) Type

func (c *Value) Type() reflect.Type

Jump to

Keyboard shortcuts

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