Documentation ¶
Index ¶
- Variables
- func And(parsers ...configo.ParserFunc) configo.ParserFunc
- func AtomicFloat32(out *float32) configo.ParserFunc
- func AtomicFloat64(out *float64) configo.ParserFunc
- func AtomicInt32(out *int32) configo.ParserFunc
- func AtomicInt64(out *int64) configo.ParserFunc
- func Bool(out *bool) configo.ParserFunc
- func ChoiceFloat(out *float64, bitSize int, allowed ...float64) configo.ParserFunc
- func ChoiceInt(out *int, allowed ...int) configo.ParserFunc
- func ChoiceString(out *string, allowed ...string) configo.ParserFunc
- func Duration(out *time.Duration) configo.ParserFunc
- func Float(out *float64, bitSize int) configo.ParserFunc
- func If(condition *bool, trueCase configo.ParserFunc, falseCase configo.ParserFunc) configo.ParserFunc
- func Int(out *int) configo.ParserFunc
- func List(out *[]string, delimiter *string) configo.ParserFunc
- func ListToSet(out *map[string]bool, delimiter *string) configo.ParserFunc
- func Map(out *map[string]string, pairDelimiter, keyValueDelimiter *string) configo.ParserFunc
- func MapFromKeysSlice(out *map[string]string, keys *[]string, delimiter *string) configo.ParserFunc
- func MapReverse(out *map[string]string, pairDelimiter, keyValueDelimiter *string) configo.ParserFunc
- func Not(parser configo.ParserFunc) configo.ParserFunc
- func OnlyIf(condition *bool, trueCase configo.ParserFunc) configo.ParserFunc
- func OnlyIfNil(condition interface{}, trueCase configo.ParserFunc) configo.ParserFunc
- func OnlyIfNot(condition *bool, falseCase configo.ParserFunc) configo.ParserFunc
- func OnlyIfNotNil(condition interface{}, trueCase configo.ParserFunc) configo.ParserFunc
- func Or(parsers ...configo.ParserFunc) configo.ParserFunc
- func PathAbsDirectory(outPath *string) configo.ParserFunc
- func PathAbsDirectoryCreate(outPath *string, dirPerms ...fs.FileMode) configo.ParserFunc
- func PathAbsFile(outPath *string) configo.ParserFunc
- func PathAbsFileDirectoryCreate(outAbsFilePath *string, dirPerms ...fs.FileMode) configo.ParserFunc
- func PathDirectory(outPath *string) configo.ParserFunc
- func PathDirectoryCreate(outPath *string, dirPerms ...fs.FileMode) configo.ParserFunc
- func PathFile(outPath *string) configo.ParserFunc
- func PathFileDirectoryCreate(outFilePath *string, dirPerms ...fs.FileMode) configo.ParserFunc
- func PromptBool(out *bool, promptPrefix *string) configo.ParserFunc
- func PromptChoiceBool(out *bool, promptPrefix *string, defaultSelection ...bool) configo.ParserFunc
- func PromptChoiceFloat(out *float64, bitSize int, promptPrefix *string, allowed []float64) configo.ParserFunc
- func PromptChoiceInt(out *int, promptPrefix *string, allowed []int) configo.ParserFunc
- func PromptChoiceText(out *string, promptPrefix *string, allowed ...string) configo.ParserFunc
- func PromptFloat(out *float64, bitSize int, promptPrefix *string) configo.ParserFunc
- func PromptInt(out *int, promptPrefix *string) configo.ParserFunc
- func PromptPassword(out, promptPrefix *string, validateFunc ...func(string) error) configo.ParserFunc
- func PromptText(out, promptPrefix *string, validateFunc ...func(string) error) configo.ParserFunc
- func RangesInt(out *int, minMaxRanges ...int) configo.ParserFunc
- func Regex(out *string, regex, errMsg string) configo.ParserFunc
- func String(out *string) configo.ParserFunc
- func SyncWrapper(mu sync.Locker, f configo.ParserFunc) configo.ParserFunc
- func UniqueList(out *[]string, delimiter *string) configo.ParserFunc
- func Xor(parsers ...configo.ParserFunc) configo.ParserFunc
- type DistinctRangeListInt
- type IntRange
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPathNotFile is returned when a given path is not a file ErrPathNotFile = errors.New("not a file") // ErrPathNotDirectory is returned when an expected path is not a directory ErrPathNotDirectory = errors.New("not a directory") // ErrPathExistsButNotDir is returned when we expect a directory but get a file at a specific file path ErrPathExistsButNotDir = errors.New("path exists but is not a directory") // ErrPathExistsButNotFile is returned when we expect a file but get a directory at a specific file path ErrPathExistsButNotFile = errors.New("path exists but is not a file") // ErrPathFailedToCreateDirs is returned when the creation of a subfolder structure failed ErrPathFailedToCreateDirs = errors.New("failed to create directories") // ErrPathFailedToConstructAbs is returned when we fail to construct an absolute file path from a relative one. ErrPathFailedToConstructAbs = errors.New("failed to construct absolute path") )
var ( // Error is returned when parsing of a key fails. Error = errors.New("parsing error") )
Functions ¶
func And ¶ added in v1.5.0
func And(parsers ...configo.ParserFunc) configo.ParserFunc
And expects that all provided parsers succeed This expects ALL parsers to succeed.
func AtomicFloat32 ¶ added in v1.24.0
func AtomicFloat32(out *float32) configo.ParserFunc
AtomicFloat32 sets the out variable atomically.
func AtomicFloat64 ¶ added in v1.24.0
func AtomicFloat64(out *float64) configo.ParserFunc
AtomicFloat64 sets the out variable atomically.
func AtomicInt32 ¶ added in v1.24.0
func AtomicInt32(out *int32) configo.ParserFunc
AtomicInt32 sets the out variable atomically.
func AtomicInt64 ¶ added in v1.24.0
func AtomicInt64(out *int64) configo.ParserFunc
AtomicInt64 sets the out variable atomically.
func Bool ¶
func Bool(out *bool) configo.ParserFunc
Bool is the default function that returns a function that sets the 'out' referenced variable to the parsed value.
func ChoiceFloat ¶
func ChoiceFloat(out *float64, bitSize int, allowed ...float64) configo.ParserFunc
ChoiceFloat restricts the float value to a given set of values that are passed with the 'allowed' parameter.
func ChoiceInt ¶
func ChoiceInt(out *int, allowed ...int) configo.ParserFunc
ChoiceInt restricts the integer value to a given set of values that are passed with the 'allowed' parameter.
func ChoiceString ¶
func ChoiceString(out *string, allowed ...string) configo.ParserFunc
ChoiceString restricts the string value to a given set of values that are passed with the 'allowed' parameter.
func Duration ¶
func Duration(out *time.Duration) configo.ParserFunc
Duration parses a string containing a duration value in the format of: 13h55m33s, 5m, 1h, 5m10s, 5m3s, etc. and returns the duration to the passed out pointer
func Float ¶
func Float(out *float64, bitSize int) configo.ParserFunc
Float parses a passed value and sets the passed out reference to the resulting value, returns an error otherwise.
func If ¶ added in v1.15.0
func If(condition *bool, trueCase configo.ParserFunc, falseCase configo.ParserFunc) configo.ParserFunc
If conditional allows to use different parsers based on the passed condition.
func Int ¶
func Int(out *int) configo.ParserFunc
Int parses a passed value and sets the passed out reference to the resulting value, returns an error otherwise.
func List ¶
func List(out *[]string, delimiter *string) configo.ParserFunc
List parses a string containing a 'delimiter'(space, comma, semicolon, etc.) delimited list into the string list 'out'
func ListToSet ¶
func ListToSet(out *map[string]bool, delimiter *string) configo.ParserFunc
ListToSet parses a string containing a 'delimiter'(space, comma, semicolon, etc.) delimited list into set 'out'
func Map ¶
func Map(out *map[string]string, pairDelimiter, keyValueDelimiter *string) configo.ParserFunc
Map allows to define key->value associations directly inside of a single parameter
func MapFromKeysSlice ¶
MapFromKeysSlice fills the 'out' map with the keys and for each key the corresponding value at the exact same position of the passed "value" string that is split into another list is creates. keys{0, 1, 2, 3} -> values{0, 1, 2, 3}
func MapReverse ¶ added in v1.10.0
func MapReverse(out *map[string]string, pairDelimiter, keyValueDelimiter *string) configo.ParserFunc
MapReverse allows to define a value->key associations directly inside of a single parameter This might be useful if you want to construct a two way mapping that is able to associate a key to a value as well as the association form a value back to its key.
func Not ¶ added in v1.20.0
func Not(parser configo.ParserFunc) configo.ParserFunc
Not negates the result of a given parser
func OnlyIf ¶ added in v1.21.0
func OnlyIf(condition *bool, trueCase configo.ParserFunc) configo.ParserFunc
OnlyIf executes the trueCase action only in the case that the condition is true
func OnlyIfNil ¶ added in v1.22.0
func OnlyIfNil(condition interface{}, trueCase configo.ParserFunc) configo.ParserFunc
OnlyIfNotNil executes the trueCase function when the condition is nil at evaluation time
func OnlyIfNot ¶ added in v1.25.0
func OnlyIfNot(condition *bool, falseCase configo.ParserFunc) configo.ParserFunc
OnlyIfNot executes the falseCase action only in the case that the condition is false
func OnlyIfNotNil ¶ added in v1.22.0
func OnlyIfNotNil(condition interface{}, trueCase configo.ParserFunc) configo.ParserFunc
OnlyIfNotNil executes the trueCase function when the condition is NOT nil at evaluation time
func Or ¶ added in v1.5.0
func Or(parsers ...configo.ParserFunc) configo.ParserFunc
Or succeeds if any of the provided functions result in a successful state Basically trying to parse the value with all prvided parsing function, until the first of those functions does not return an error. In case all of these parsers return an error, the returned parser function also returns an error constructed of all other errors This basically expects ANY of the parsers to succeed
func PathAbsDirectory ¶ added in v1.27.0
func PathAbsDirectory(outPath *string) configo.ParserFunc
PathAbsDirectory checks whether the value (e.g. environment value, map string value) is a valid directory path. Returns an error in case that the path location does not exist or is not a directory. The returned outPath is an absolute path.
func PathAbsDirectoryCreate ¶ added in v1.27.0
func PathAbsDirectoryCreate(outPath *string, dirPerms ...fs.FileMode) configo.ParserFunc
PathAbsDirectoryCreate checks whether the value (e.g. environment value, map string value) is a valid directory path. Returns an error in case that the path location does not exist or is not a directory. dirPerms is set to a single default value. You may provide a single octal 0700 directory permission that is applied to all newly created sub directories. The returned directory path is an absolute path.
func PathAbsFile ¶ added in v1.27.0
func PathAbsFile(outPath *string) configo.ParserFunc
PathAbsFile checks whether the value (e.g. environment value, map string value) is a valid file path. Returns an error in case that the path location does not exist or is not a file. The returned outPath is an absolute path.
func PathAbsFileDirectoryCreate ¶ added in v1.27.0
func PathAbsFileDirectoryCreate(outAbsFilePath *string, dirPerms ...fs.FileMode) configo.ParserFunc
PathFileDirectoryCreate checks whether the value (e.g. environment value, map string value) is a valid file path. In case that the file path does not exist, all directories of that file path are created In case that the final file already exists, we do not creat eanything. Beware, the file itself is never created with this, only the folder structure that is supposed to contain the file. dirPerms takes the first passed octal formated permission or defaults to 0700.
func PathDirectory ¶ added in v1.27.0
func PathDirectory(outPath *string) configo.ParserFunc
PathDirectory checks whether the value (e.g. environment value, map string value) is a valid directory path. Returns an error in case that the path location does not exist or is not a directory.
func PathDirectoryCreate ¶ added in v1.27.0
func PathDirectoryCreate(outPath *string, dirPerms ...fs.FileMode) configo.ParserFunc
PathDirectoryCreate checks whether the value (e.g. environment value, map string value) is a valid directory path. Returns an error in case that the path location does not exist or is not a directory. dirPerms is set to a single default value. You may provide a single octal 0700 directory permission that is applied to all newly created sub directories.
func PathFile ¶ added in v1.27.0
func PathFile(outPath *string) configo.ParserFunc
PathFile checks whether the value (e.g. environment value, map string value) is a valid file path. Returns an error in case that the path location does not exist or is not a file.
func PathFileDirectoryCreate ¶ added in v1.27.0
func PathFileDirectoryCreate(outFilePath *string, dirPerms ...fs.FileMode) configo.ParserFunc
PathFileDirectoryCreate checks whether the value (e.g. environment value, map string value) is a valid file path. In case that the file path does not exist, all directories of that file path are created In case that the final file already exists, we do not creat eanything. Beware, the file itself is never created with this, only the folder structure that is supposed to contain the file. dirPerms takes the first passed octal formated permission or defaults to 0700.
func PromptBool ¶ added in v1.24.0
func PromptBool(out *bool, promptPrefix *string) configo.ParserFunc
PromptBool prompts the user to enter a boolean. This only prompts the user in the case that the corresponding environment variable does not contain any string data.
func PromptChoiceBool ¶ added in v1.24.0
func PromptChoiceBool(out *bool, promptPrefix *string, defaultSelection ...bool) configo.ParserFunc
PromptChoiceBool prompts the user to select one of the provided "y/n". This only prompts the user in the case that the corresponding environment variable does not contain any string data.
func PromptChoiceFloat ¶ added in v1.24.0
func PromptChoiceFloat(out *float64, bitSize int, promptPrefix *string, allowed []float64) configo.ParserFunc
PromptChoiceFloat prompts the user to select one of the provided floats. This only prompts the user in the case that the corresponding environment variable does not contain any string data.
func PromptChoiceInt ¶ added in v1.24.0
func PromptChoiceInt(out *int, promptPrefix *string, allowed []int) configo.ParserFunc
PromptChoiceInt prompts the user to select one of the provided integers. This only prompts the user in the case that the corresponding environment variable does not contain any string data.
func PromptChoiceText ¶ added in v1.24.0
func PromptChoiceText(out *string, promptPrefix *string, allowed ...string) configo.ParserFunc
PromptChoiceText prompts the user to select one of the provided strings. This only prompts the user in the case that the corresponding environment variable does not contain any string data.
func PromptFloat ¶ added in v1.24.0
func PromptFloat(out *float64, bitSize int, promptPrefix *string) configo.ParserFunc
PromptFloat prompts the user to enter a float. This only prompts the user in the case that the corresponding environment variable does not contain any string data.
func PromptInt ¶ added in v1.24.0
func PromptInt(out *int, promptPrefix *string) configo.ParserFunc
PromptInt prompts the user to enter a string. This only prompts the user in the case that the corresponding environment variable does not contain any string data.
func PromptPassword ¶
func PromptPassword(out, promptPrefix *string, validateFunc ...func(string) error) configo.ParserFunc
PromptPassword prompts the user for the password in case the to be parsed map value does not contain any string data, meaning the user is only prompted when the e.g. environment variable doe snot exist or is empty.
func PromptText ¶
func PromptText(out, promptPrefix *string, validateFunc ...func(string) error) configo.ParserFunc
PromptText prompts the user to enter a text. This only prompts the user in the case that the corresponding environment variable does not contain any string data.
func RangesInt ¶
func RangesInt(out *int, minMaxRanges ...int) configo.ParserFunc
RangesInt restricts the integer value to a distinct list of min-max ranges. If the passed value to the returned function is not in any of these ranges, an error is returned. Example minMaxRange: #1: 0,1024 # range from 0 through 1024 #2: 0,3,9,10 # range from 0 through 3 and from 9 through 10 #3: 0,10,2,12 # rage from 0 through 12
func Regex ¶
func Regex(out *string, regex, errMsg string) configo.ParserFunc
Regex allows the value of a key to be compliant to a regular expression.
func String ¶
func String(out *string) configo.ParserFunc
String is the default function that returns a function that sets the parsed value to the passed referenced variable out is a pointer to the variable that gets the parsed value assigned to.
func SyncWrapper ¶ added in v1.24.0
func SyncWrapper(mu sync.Locker, f configo.ParserFunc) configo.ParserFunc
SyncWrapper allows to wrap ParseFunc in a synchronized context. This allows to execute the parsing in an asynchronous context. which prevents data races even in the case that the configuration periodically kept up to date.
func UniqueList ¶
func UniqueList(out *[]string, delimiter *string) configo.ParserFunc
UniqueList enforces that the passed list contains only unique values
func Xor ¶ added in v1.5.0
func Xor(parsers ...configo.ParserFunc) configo.ParserFunc
Xor enforces that only one of the functions results in a successful result. all of the other results are expected to yield an error, otherwise this function returns an error. This basically expects only ONE of the parsers to succeed.
Types ¶
type DistinctRangeListInt ¶
type DistinctRangeListInt struct {
// contains filtered or unexported fields
}
func NewDistinctRangeListInt ¶
func NewDistinctRangeListInt(minMaxRanges ...int) DistinctRangeListInt
func (*DistinctRangeListInt) Contains ¶
func (d *DistinctRangeListInt) Contains(i int) bool
func (*DistinctRangeListInt) String ¶
func (d *DistinctRangeListInt) String() string