Documentation ¶
Index ¶
- type BoolNode
- type Config
- func (c *Config) GetArray(path string) (vals []*Config, err error)
- func (c *Config) GetBool(path string) (val bool, err error)
- func (c *Config) GetComplex(path string) (val complex128, err error)
- func (c *Config) GetDefaultBool(path string, defaultVal bool) bool
- func (c *Config) GetDefaultComplex(path string, defaultVal complex128) complex128
- func (c *Config) GetDefaultFloat(path string, defaultVal float64) float64
- func (c *Config) GetDefaultInt(path string, defaultVal int64) int64
- func (c *Config) GetDefaultString(path string, defaultVal string) string
- func (c *Config) GetDefaultUInt(path string, defaultVal uint64) uint64
- func (c *Config) GetFloat(path string) (val float64, err error)
- func (c *Config) GetInt(path string) (val int64, err error)
- func (c *Config) GetString(path string) (val string, err error)
- func (c *Config) GetUInt(path string) (val uint64, err error)
- func (c *Config) GetValue(path string) (conf *Config, err error)
- func (c *Config) String() string
- type FieldNode
- type ListNode
- type MapNode
- type NilNode
- type Node
- type NodeType
- type NumberNode
- type Pos
- type StringNode
- type TextNode
- type Tree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoolNode ¶
type BoolNode struct { NodeType Pos True bool // The value of the boolean constant. // contains filtered or unexported fields }
BoolNode holds a boolean constant.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func (*Config) GetComplex ¶
func (c *Config) GetComplex(path string) (val complex128, err error)
func (*Config) GetDefaultComplex ¶
func (c *Config) GetDefaultComplex(path string, defaultVal complex128) complex128
func (*Config) GetDefaultFloat ¶
func (*Config) GetDefaultString ¶
func (*Config) GetDefaultUInt ¶
type FieldNode ¶
type FieldNode struct { NodeType Pos Ident []string // The identifiers in lexical order. // contains filtered or unexported fields }
FieldNode holds a field (identifier starting with '.'). The names may be chained ('.x.y'). The period is dropped from each ident.
type ListNode ¶
type ListNode struct { NodeType Pos Nodes []Node // The element nodes in lexical order. // contains filtered or unexported fields }
ListNode holds a sequence of nodes.
type MapNode ¶
type MapNode struct { NodeType Pos Nodes map[string]Node // contains filtered or unexported fields }
MapNode holds a map of nodes.
type Node ¶
type Node interface { Type() NodeType String() string // Copy does a deep copy of the Node and all its components. // To avoid type assertions, some XxxNodes also have specialized // CopyXxx methods that return *XxxNode. Copy() Node Position() Pos // byte position of start of node in full original input string // contains filtered or unexported methods }
A Node is an element in the parse tree. The interface is trivial. The interface contains an unexported method so that only types local to this package can satisfy it.
type NumberNode ¶
type NumberNode struct { NodeType Pos IsInt bool // Number has an integral value. IsUint bool // Number has an unsigned integral value. IsFloat bool // Number has a floating-point value. IsComplex bool // Number is complex. Int64 int64 // The signed integer value. Uint64 uint64 // The unsigned integer value. Float64 float64 // The floating-point value. Complex128 complex128 // The complex value. Text string // The original textual representation from the input. // contains filtered or unexported fields }
NumberNode holds a number: signed or unsigned integer, float, or complex. The value is parsed and stored under all the types that can represent the value. This simulates in a small amount of code the behavior of Go's ideal constants.
func (*NumberNode) Copy ¶
func (n *NumberNode) Copy() Node
func (*NumberNode) String ¶
func (n *NumberNode) String() string
type Pos ¶
type Pos int
Pos represents a byte position in the original input text from which this template was parsed.
type StringNode ¶
type StringNode struct { NodeType Pos Quoted string // The original text of the string, with quotes. Text string // The string, after quote processing. // contains filtered or unexported fields }
StringNode holds a string constant. The value has been "unquoted".
func (*StringNode) Copy ¶
func (s *StringNode) Copy() Node
func (*StringNode) String ¶
func (s *StringNode) String() string
type TextNode ¶
type TextNode struct { NodeType Pos Text []byte // The text; may span newlines. // contains filtered or unexported fields }
TextNode holds plain text.
type Tree ¶
type Tree struct { Name string // name of the template represented by the tree. ParseName string // name of the top-level template during parsing, for error messages. Root Node // top-level root of the tree. // contains filtered or unexported fields }
Tree is the representation of a single parsed template.
func Parse ¶
Parse returns a map from template name to parse.Tree, created by parsing the templates described in the argument string. The top-level template will be given the specified name. If an error is encountered, parsing stops and an empty map is returned with the error.
func (*Tree) ErrorContext ¶
ErrorContext returns a textual representation of the location of the node in the input text. The receiver is only used when the node does not have a pointer to the tree inside, which can occur in old code.