Documentation
¶
Overview ¶
Package structure provides a flag Value which can be used to initialize a structure. Under the covers, mergo is used. The default configuration supports string-based conversion from all the types that joe-cli supports built-in.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
func Decode(input, output any, opts ...DecoderOption) error
Decode will apply values to the given output
func ErrorUnused ¶
func ErrorUnused(cfg *mapstructure.DecoderConfig)
ErrorUnused is an option which makes it an error to have input specify fields that are unused by the decoder
Types ¶
type DecoderOption ¶
type DecoderOption func(*mapstructure.DecoderConfig)
DecoderOption provides an option to the decoder
type Value ¶
type Value struct {
// V is the value that is actually initialized, a pointer to the struct.
V any
// Options specifies the mapstructure options to use during the conversion.
// If nil, some default options are specified that supports viable weakly typed
// parsing. To stop this, the options must be explicitly set to non-nil slice
// (or some other custom decoder config)
Options []DecoderOption
// contains filtered or unexported fields
}
Value is a value that uses structured initialization. This allows arbitrary key value pairs to be used to initialize the inner value. It uses the same semantics and syntax as cli.Map, including the short hand key-value pair syntax, a flag with multiple occurrences, and disabling splitting.
func Of ¶
Of creates a Value which can be initialized using name-value pairs. The argument v must be a pointer to a struct. By default, a set of viable options provide conversions is also specified. (To stop this, you must set or clear Options directly)
func (*Value) DisableSplitting ¶
func (v *Value) DisableSplitting()
DisableSplitting causes commas to be treated literally instead of as delimiters between values.
func (*Value) WithOptions ¶
func (v *Value) WithOptions(options ...DecoderOption) *Value
WithOptions applies additional options.