anko: github.com/mattn/anko/env Index | Files

package env

import "github.com/mattn/anko/env"

Index

Package Files

env.go envTypes.go envValues.go

Variables

var (
    // Packages is a where packages can be stored so VM import command can be used to import them.
    // reflect.Value must be valid or VM may crash.
    // For nil must use NilValue.
    Packages = make(map[string]map[string]reflect.Value)
    // PackageTypes is a where package types can be stored so VM import command can be used to import them
    // reflect.Type must be valid or VM may crash.
    // For nil type must use NilType.
    PackageTypes = make(map[string]map[string]reflect.Type)

    // NilType is the reflect.type of nil
    NilType = reflect.TypeOf(nil)
    // NilValue is the reflect.value of nil
    NilValue = reflect.New(reflect.TypeOf((*interface{})(nil)).Elem()).Elem()

    // ErrSymbolContainsDot symbol contains .
    ErrSymbolContainsDot = errors.New("symbol contains '.'")
)

type Env Uses

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

Env is the environment needed for a VM to run in.

func NewEnv Uses

func NewEnv() *Env

NewEnv creates new global scope.

func (*Env) Addr Uses

func (e *Env) Addr(symbol string) (reflect.Value, error)

Addr returns reflect.Addr of value for first matching symbol found in current or parent scope.

func (*Env) Copy Uses

func (e *Env) Copy() *Env

Copy the Env for current scope

func (*Env) DeepCopy Uses

func (e *Env) DeepCopy() *Env

DeepCopy the Env for current scope and parent scopes. Note that each scope is a consistent snapshot but not the whole.

func (*Env) Define Uses

func (e *Env) Define(symbol string, value interface{}) error

Define defines/sets interface value to symbol in current scope.

func (*Env) DefineGlobal Uses

func (e *Env) DefineGlobal(symbol string, value interface{}) error

DefineGlobal defines/sets interface value to symbol in global scope.

func (*Env) DefineGlobalReflectType Uses

func (e *Env) DefineGlobalReflectType(symbol string, reflectType reflect.Type) error

DefineGlobalReflectType defines type in global scope.

func (*Env) DefineGlobalType Uses

func (e *Env) DefineGlobalType(symbol string, aType interface{}) error

DefineGlobalType defines type in global scope.

func (*Env) DefineGlobalValue Uses

func (e *Env) DefineGlobalValue(symbol string, value reflect.Value) error

DefineGlobalValue defines/sets reflect value to symbol in global scope.

func (*Env) DefineReflectType Uses

func (e *Env) DefineReflectType(symbol string, reflectType reflect.Type) error

DefineReflectType defines type in current scope.

func (*Env) DefineType Uses

func (e *Env) DefineType(symbol string, aType interface{}) error

DefineType defines type in current scope.

func (*Env) DefineValue Uses

func (e *Env) DefineValue(symbol string, value reflect.Value) error

DefineValue defines/sets reflect value to symbol in current scope.

func (*Env) Delete Uses

func (e *Env) Delete(symbol string)

Delete deletes symbol in current scope.

func (*Env) DeleteGlobal Uses

func (e *Env) DeleteGlobal(symbol string)

DeleteGlobal deletes the first matching symbol found in current or parent scope.

func (*Env) Get Uses

func (e *Env) Get(symbol string) (interface{}, error)

Get returns interface value from the scope where symbol is frist found.

func (*Env) GetEnvFromPath Uses

func (e *Env) GetEnvFromPath(path []string) (*Env, error)

GetEnvFromPath returns Env from path

func (*Env) GetValue Uses

func (e *Env) GetValue(symbol string) (reflect.Value, error)

GetValue returns reflect value from the scope where symbol is frist found.

func (*Env) NewEnv Uses

func (e *Env) NewEnv() *Env

NewEnv creates new child scope.

func (*Env) NewModule Uses

func (e *Env) NewModule(symbol string) (*Env, error)

NewModule creates new child scope and define it as a symbol. This is a shortcut for calling e.NewEnv then Define that new Env.

func (*Env) Set Uses

func (e *Env) Set(symbol string, value interface{}) error

Set interface value to the scope where symbol is frist found.

func (*Env) SetExternalLookup Uses

func (e *Env) SetExternalLookup(externalLookup ExternalLookup)

SetExternalLookup sets an external lookup

func (*Env) SetValue Uses

func (e *Env) SetValue(symbol string, value reflect.Value) error

SetValue reflect value to the scope where symbol is frist found.

func (*Env) String Uses

func (e *Env) String() string

String returns string of values and types in current scope.

func (*Env) Type Uses

func (e *Env) Type(symbol string) (reflect.Type, error)

Type returns reflect type from the scope where symbol is frist found.

type ExternalLookup Uses

type ExternalLookup interface {
    Get(string) (reflect.Value, error)
    Type(string) (reflect.Type, error)
}

ExternalLookup for Env external lookup of values and types.

Package env imports 6 packages (graph) and is imported by 13 packages. Updated 2020-03-26. Refresh now. Tools for package owners.