vars

package
v0.0.0-...-c555478 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package vars provides a framework for language vars.

Index

Constants

View Source
const (
	// ConstNamespace is the string prefix for all top-level built-in vars.
	ConstNamespace = "const"

	// ResourceNamespace is the string prefix for all top-level resource
	// specific built-in vars, that exist under the ConstNamespace header.
	ResourceNamespace = "res"
)

Variables

This section is empty.

Functions

func Lookup

func Lookup(name string) (interfaces.Var, error)

Lookup returns a pointer to the var implementation.

func LookupPrefix

func LookupPrefix(prefix string) map[string]func() interfaces.Var

LookupPrefix returns a map of names to vars that start with a module prefix. This search automatically adds the period separator. So if you want vars in the `const` prefix, search for `const`, not `const.` and it will find all the correctly registered vars. This removes that prefix from the result in the map keys that it returns. If you search for an empty prefix, then this will return all the top-level functions that aren't in a module.

func Map

func Map() map[string]func() interfaces.Var

Map returns a map from all registered var names to a function to return that one. We return a copy of our internal registered var store so that this result can be manipulated safely. We return the vars that produce the Var interface because we might use this result to create multiple vars, and each one might need to have its own unique memory address to work properly.

func Register

func Register(name string, fn func() interfaces.Var)

Register takes a var and its name and makes it available for use. It is commonly called in the init() method of the var at program startup. There is no matching Unregister function.

func RegisterResourceParam

func RegisterResourceParam(kind, param, field string, value func() interfaces.Var)

RegisterResourceParam registers a single const param for a resource. You might prefer to use RegisterResourceParams instead.

func RegisterResourceParams

func RegisterResourceParams(kind string, params map[string]map[string]func() interfaces.Var)

RegisterResourceParams registers a map of const params for a resource. The params mapping keys are the param name and the param field name. Finally, the value is the specific type value for that constant.

Types

This section is empty.

Jump to

Keyboard shortcuts

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