{"modulePath":"github.com/foxcpp/maddy","version":"v0.9.8","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package config\n\n## Variables\n\n```go\nvar (\n\t// StateDirectory contains the path to the directory that\n\t// should be used to store any data that should be\n\t// preserved between sessions.\n\t//\n\t// Value of this variable must not change after initialization\n\t// in cmd/maddy/main.go.\n\tStateDirectory string\n\n\t// RuntimeDirectory contains the path to the directory that\n\t// should be used to store any temporary data.\n\t//\n\t// It should be preferred over os.TempDir, which is\n\t// global and world-readable on most systems, while\n\t// RuntimeDirectory can be dedicated for maddy.\n\t//\n\t// Value of this variable must not change after initialization\n\t// in cmd/maddy/main.go.\n\tRuntimeDirectory string\n\n\t// LibexecDirectory contains the path to the directory\n\t// where helper binaries should be searched.\n\t//\n\t// Value of this variable must not change after initialization\n\t// in cmd/maddy/main.go.\n\tLibexecDirectory string\n)\n```\n\n## Functions\n\n```go\nfunc EnumListMapped[V any](m *Map, name string, inheritGlobal, required bool, mapped map[string]V, defaultVal []V, store *[]V)\n```\nEnumListMapped is similar to Map.EnumList but maps a stirng to a custom type.\n\n```go\nfunc EnumMapped[V any](m *Map, name string, inheritGlobal, required bool, mapped map[string]V, defaultVal V, store *V)\n```\nEnumMapped is similar to Map.Enum but maps a stirng to a custom type.\n\n```go\nfunc NodeErr(node Node, f string, args ...interface{}) error\n```\n\n```go\nfunc ParseBool(s string) (bool, error)\n```\n\n```go\nfunc ParseDataSize(s string) (int, error)\n```\n\n## Types\n\n```go\ntype Endpoint struct {\n\tOriginal, Scheme, SchemeModifier, Host, Port, Path string\n}\n```\nEndpoint represents a site address. It contains the original input value, and the component parts of an address. The component parts may be updated to the correct values as setup proceeds, but the original value should never be changed.\n\n```go\nfunc ParseEndpoint(str string) (Endpoint, error)\n```\nParseEndpoint parses an endpoint string into a structured format with separate scheme, host, port, and path portions, as well as the original input string.\n\n```go\nfunc (e Endpoint) Address() string\n```\n\n```go\nfunc (e Endpoint) IsFD() bool\n```\n\n```go\nfunc (e Endpoint) IsTLS() bool\n```\n\n```go\nfunc (e Endpoint) Network() string\n```\n\n```go\nfunc (e Endpoint) String() string\n```\nString returns a human-friendly print of the address.\n\n```go\ntype Map struct {\n\n\t// All values saved by Map during processing.\n\tValues map[string]interface{}\n\n\t// Values used by Process as default values if inheritGlobal is true.\n\tGlobals map[string]interface{}\n\t// Config block used by Process.\n\tBlock Node\n\t// contains filtered or unexported fields\n}\n```\nMap structure implements reflection-based conversion between configuration directives and Go variables.\n\n```go\nfunc NewMap(globals map[string]interface{}, block Node) *Map\n```\n\n```go\nfunc (m *Map) AllowUnknown()\n```\nAllowUnknown makes config.Map skip unknown configuration directives instead of failing.\n\n```go\nfunc (m *Map) Bool(name string, inheritGlobal, defaultVal bool, store *bool)\n```\nBool maps presence of some configuration directive to a boolean variable. Additionally, 'name yes' and 'name no' are mapped to true and false correspondingly.\n\nI.e. if directive 'io\\_debug' exists in processed configuration block or in the global configuration (if inheritGlobal is true) then Process will store true in target variable.\n\n```go\nfunc (m *Map) Callback(name string, mapper func(*Map, Node) error)\n```\nCallback creates mapping that will call mapper() function for each directive with the specified name. No further processing is done.\n\nDirectives with the specified name will not be returned by Process if AllowUnknown is used.\n\nIt is intended to permit multiple independent values of directive with implementation-defined handling.\n\n```go\nfunc (m *Map) Custom(name string, inheritGlobal, required bool, defaultVal func() (interface{}, error), mapper func(*Map, Node) (interface{}, error), store interface{})\n```\nCustom maps configuration directive with the specified name to variable referenced by 'store' pointer.\n\nIf inheritGlobal is true - Map will try to use a value from globalCfg if none is set in a processed configuration block.\n\nIf required is true - Map will fail if no value is set in the configuration, both global (if inheritGlobal is true) and in the processed block.\n\ndefaultVal is a factory function that should return the default value for the variable. It will be used if no value is set in the config. It can be nil if required is true. Note that if inheritGlobal is true, defaultVal of the global directive will be used instead.\n\nmapper is a function that should convert configuration directive arguments into variable value.  Both functions may fail with errors, configuration processing will stop immediately then. Note: mapper function should not modify passed values.\n\nstore is where the value returned by mapper should be stored. Can be nil (value will be saved only in Map.Values).\n\n```go\nfunc (m *Map) DataSize(name string, inheritGlobal, required bool, defaultVal int64, store *int64)\n```\nDataSize maps configuration directive to a int variable, representing data size.\n\nSyntax requires unit suffix to be added to the end of string to specify data unit and allows multiple arguments (they will be added together).\n\nSee Map.Custom for description of arguments.\n\n```go\nfunc (m *Map) Duration(name string, inheritGlobal, required bool, defaultVal time.Duration, store *time.Duration)\n```\nDuration maps configuration directive to a time.Duration variable.\n\nDirective must be in form 'name duration' where duration is any string accepted by time.ParseDuration. As an additional requirement, result of time.ParseDuration must not be negative.\n\nNote that for convenience, if directive does have multiple arguments, they will be joined without separators. E.g. 'name 1h 2m' will become 'name 1h2m' and so '1h2m' will be passed to time.ParseDuration.\n\nSee Map.Custom for description of arguments.\n\n```go\nfunc (m *Map) Enum(name string, inheritGlobal, required bool, allowed []string, defaultVal string, store *string)\n```\nEnum maps a configuration directive to a string variable.\n\nDirective must be in form 'name string' where string should be from \\*allowed\\* slice. That string argument will be stored in store variable.\n\nSee Map.Custom for description of inheritGlobal and required.\n\n```go\nfunc (m *Map) EnumList(name string, inheritGlobal, required bool, allowed, defaultVal []string, store *[]string)\n```\nEnumList maps a configuration directive to a \\[]string variable.\n\nDirective must be in form 'name string1 string2' where each string should be from \\*allowed\\* slice. At least one argument should be present.\n\nSee Map.Custom for description of inheritGlobal and required.\n\n```go\nfunc (m *Map) Float(name string, inheritGlobal, required bool, defaultVal float64, store *float64)\n```\nFloat maps configuration directive with the specified name to variable referenced by 'store' pointer.\n\nConfiguration directive must be in form 'name 123.55'.\n\nSee Custom function for details about inheritGlobal, required and defaultVal.\n\n```go\nfunc (m *Map) Int(name string, inheritGlobal, required bool, defaultVal int, store *int)\n```\nInt maps configuration directive with the specified name to variable referenced by 'store' pointer.\n\nConfiguration directive must be in form 'name 123'.\n\nSee Custom function for details about inheritGlobal, required and defaultVal.\n\n```go\nfunc (m *Map) Int32(name string, inheritGlobal, required bool, defaultVal int32, store *int32)\n```\nInt32 maps configuration directive with the specified name to variable referenced by 'store' pointer.\n\nConfiguration directive must be in form 'name 123'.\n\nSee Custom function for details about inheritGlobal, required and defaultVal.\n\n```go\nfunc (m *Map) Int64(name string, inheritGlobal, required bool, defaultVal int64, store *int64)\n```\nInt64 maps configuration directive with the specified name to variable referenced by 'store' pointer.\n\nConfiguration directive must be in form 'name 123'.\n\nSee Custom function for details about inheritGlobal, required and defaultVal.\n\n```go\nfunc (m *Map) Process() (unknown []Node, err error)\n```\nProcess maps variables from global configuration and block passed in NewMap.\n\nIf Map instance was not created using NewMap - Process panics.\n\n```go\nfunc (m *Map) ProcessWith(globalCfg map[string]interface{}, block Node) (unknown []Node, err error)\n```\nProcess maps variables from global configuration and block passed in arguments.\n\n```go\nfunc (m *Map) String(name string, inheritGlobal, required bool, defaultVal string, store *string)\n```\nString maps configuration directive with the specified name to variable referenced by 'store' pointer.\n\nConfiguration directive must be in form 'name arbitrary\\_string'.\n\nSee Custom function for details about inheritGlobal, required and defaultVal.\n\n```go\nfunc (m *Map) StringList(name string, inheritGlobal, required bool, defaultVal []string, store *[]string)\n```\nStringList maps configuration directive with the specified name to variable referenced by 'store' pointer.\n\nConfiguration directive must be in form 'name arbitrary\\_string arbitrary\\_string ...' Where at least one argument must be present.\n\nSee Custom function for details about inheritGlobal, required and defaultVal.\n\n```go\nfunc (m *Map) UInt(name string, inheritGlobal, required bool, defaultVal uint, store *uint)\n```\nUInt maps configuration directive with the specified name to variable referenced by 'store' pointer.\n\nConfiguration directive must be in form 'name 123'.\n\nSee Custom function for details about inheritGlobal, required and defaultVal.\n\n```go\nfunc (m *Map) UInt32(name string, inheritGlobal, required bool, defaultVal uint32, store *uint32)\n```\nUInt32 maps configuration directive with the specified name to variable referenced by 'store' pointer.\n\nConfiguration directive must be in form 'name 123'.\n\nSee Custom function for details about inheritGlobal, required and defaultVal.\n\n```go\nfunc (m *Map) UInt64(name string, inheritGlobal, required bool, defaultVal uint64, store *uint64)\n```\nUInt64 maps configuration directive with the specified name to variable referenced by 'store' pointer.\n\nConfiguration directive must be in form 'name 123'.\n\nSee Custom function for details about inheritGlobal, required and defaultVal.\n\n```go\ntype Node = parser.Node\n```\n\n","path":"github.com/foxcpp/maddy/framework/config","name":"config","synopsis":"","isRedistributable":true}
