Documentation ¶
Overview ¶
The Tideland Go Library etc configuration package provides the reading, parsing, and accessing of configuration data. Different readers can be passed as sources for the SML formatted input.
Index ¶
Constants ¶
const ( ErrIllegalSourceFormat = iota + 1 ErrIllegalConfigSource ErrCannotReadFile ErrInvalidPath ErrCannotApply )
Variables ¶
This section is empty.
Functions ¶
func IsInvalidPathError ¶
IsInvalidPathError checks if a path cannot be found.
func PackageVersion ¶
PackageVersion returns the version of the version package.
Types ¶
type Etc ¶
type Etc interface { fmt.Stringer // ValueAsString retrieves the string value at a given path. If it // doesn't exist the default value dv is returned. ValueAsString(path, dv string) string // ValueAsBool retrieves the bool value at a given path. If it // doesn't exist the default value dv is returned. ValueAsBool(path string, dv bool) bool // ValueAsInt retrieves the int value at a given path. If it // doesn't exist the default value dv is returned. ValueAsInt(path string, dv int) int // ValueAsFloat64 retrieves the float64 value at a given path. If it // doesn't exist the default value dv is returned. ValueAsFloat64(path string, dv float64) float64 // ValueAsTime retrieves the string value at a given path and // interprets it as time with the passed format. If it // doesn't exist the default value dv is returned. ValueAsTime(path, layout string, dv time.Time) time.Time // ValueAsDuration retrieves the duration value at a given path. // If it doesn't exist the default value dv is returned. ValueAsDuration(path string, dv time.Duration) time.Duration // Apply creates a new configuration by adding of overwriting // the passed values. The keys of the map have to be slash // separated configuration paths without the leading "etc". Apply(kvs map[string]string) (Etc, error) }
Etc contains the read etc configuration and provides access to it. The root node "etc" is automatically preceded to the path. The node name have to consist out of 'a' to 'z', '0' to '9', and '-'. The nodes of a path are separated by '/'.
func Read ¶
Read reads the SML source of the configuration from a reader, parses it, and returns the etc instance.
func ReadFile ¶
ReadFile reads the SML source of a configuration file, parses it, and returns the etc instance.
func ReadString ¶
ReadString reads the SML source of the configuration from a string, parses it, and returns the etc instance.