Documentation
¶
Overview ¶
Package config provides types that represent a plugin's configuration.
The types provided in this package are fairly low level and correspond directly to types in collectd:
· "Block" corresponds to "oconfig_item_t".
· "Value" corresponds to "oconfig_value_t".
Blocks contain a Key, and optionally Values and/or children (nested Blocks). In collectd's configuration, these pieces are represented as follows:
<Key "Value"> Child "child value" </Key>
In Go, this would be represented as:
Block{ Key: "Key", Values: []Value{String("Value")}, Children: []Block{ { Key: "Child", Values: []Value{String("child value")}, }, }, }
The recommended way to work with configurations is to define a data type representing the configuration, then use "Block.Unmarshal" to map the Block representation onto the data type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
Block represents one configuration block, which may contain other configuration blocks.
func (*Block) MarshalText ¶
MarshalText produces a text version of Block. The result is parseable by collectd. Implements the "encoding".TextMarshaler interface.
type Port ¶
type Port int
Port represents a port number in the configuration. When a configuration is converted to Go types using Unmarshal, it implements special conversion rules: If the config option is a numeric value, it is ensured to be in the range [1–65535]. If the config option is a string, it is converted to a port number using "net".LookupPort (using "tcp" as network).
func (*Port) UnmarshalConfig ¶
UnmarshalConfig converts b to a port number.
type Unmarshaler ¶
Unmarshaler is the interface implemented by types that can unmarshal a Block representation of themselves.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value may be either a string, float64 or boolean value. This is the Go equivalent of the C type "oconfig_value_t".
func Values ¶
func Values(values ...interface{}) []Value
Values allocates and initializes a []Value slice. "string", "float64", and "bool" are mapped directly. "[]byte" is converted to a string. Numeric types (except complex numbers) are converted to float64. All other values are converted to string using the `%v` format.
func (Value) Interface ¶
func (cv Value) Interface() interface{}
Interface returns the specific value of Value without specifying its type, useful for functions like fmt.Printf which can use variables with unknown types.