Documentation ¶
Index ¶
- type Block
- func (b *Block) Any(name string) any
- func (b *Block) AnyOr(name string, defvalue any) any
- func (b *Block) Block(name string) *Block
- func (b *Block) Bool(name string) bool
- func (b *Block) BoolOr(name string, defvalue bool) bool
- func (b *Block) Duration(name string) time.Duration
- func (b *Block) DurationOr(name string, defvalue time.Duration) time.Duration
- func (b *Block) Has(name string) bool
- func (b *Block) Int(name string) int
- func (b *Block) IntOr(name string, defvalue int) int
- func (b *Block) String(name string) string
- func (b *Block) StringList(name string) []string
- func (b *Block) StringListOr(name string, defvalue []string) []string
- func (b *Block) StringOr(name string, defvalue string) string
- type BlockSpec
- type Config
- func (c *Config) Any(name string) any
- func (c *Config) AnyOr(name string, defvalue any) any
- func (c *Config) Block(name string) *Block
- func (c *Config) Bool(name string) bool
- func (c *Config) BoolOr(name string, defvalue bool) bool
- func (c *Config) Duration(name string) time.Duration
- func (c *Config) DurationOr(name string, defvalue time.Duration) time.Duration
- func (c *Config) Has(name string) bool
- func (c *Config) Int(name string) int
- func (c *Config) IntOr(name string, defvalue int) int
- func (c *Config) String(name string) string
- func (c *Config) StringList(name string) []string
- func (c *Config) StringListOr(name string, defvalue []string) []string
- func (c *Config) StringOr(name string, defvalue string) string
- type Name
- type Parser
- type Property
- type PropertySpec
- type Spec
- type Token
- type Tokenizer
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
func (*Block) DurationOr ¶
func (*Block) StringList ¶
type BlockSpec ¶
type BlockSpec struct { Name string Repeat bool Require bool Properties []*PropertySpec Blocks []*BlockSpec Strict bool }
Specification descriptor for block of properties. Block is a named group of properties. Nested blocks are allowed.
Examples:
block-a { foo = 1 block-b { bar = 2 baz = 3 } }
There is a reserved block name which has special meaning -- *. Only single star-block per nested-level is allowed. Star-block allows to define expected serie of block with arbitrary names. It can be useful when you want to allow series of uniform blocks.
Example:
sda { dev = "/dev/sda" }
sdb { dev = "/dev/sdb" }
type Config ¶
func (*Config) DurationOr ¶
func (*Config) StringList ¶
func (*Config) StringListOr ¶
type PropertySpec ¶
Specification descriptor for single property in configuration file. Proper is a key=value parir expression which assigns value for an identifier.
Examples: property-name = "string value" property-name = 100
type Spec ¶
type Spec struct { Properties []*PropertySpec Blocks []*BlockSpec Strict bool }
type Tokenizer ¶
type Tokenizer struct {
// contains filtered or unexported fields
}
func NewTokenizer ¶
type Type ¶
type Type int
const ( // Typical boolean value like true and false. TypeBool Type = iota // Duration type. Same format as Go's time.ParseDuration() uses. // See more: https://pkg.go.dev/time#ParseDuration TypeDuration // Positive integer value like 1 or 100. // TODO: Support negative values. TypeInt // String value -- sequence of characters enclosed with double quotes. TypeString // List of strings. TypeStringList )
TODO: Add Float type support.
Click to show internal directories.
Click to hide internal directories.