structure

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

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

func Of(v any) *Value

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) Set

func (v *Value) Set(arg string) error

Set the text of the value. Can be called successively to append.

func (*Value) String

func (v *Value) String() string

func (*Value) Value

func (v *Value) Value() any

Value obtains the inner value.

func (*Value) WithOptions

func (v *Value) WithOptions(options ...DecoderOption) *Value

WithOptions applies additional options.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL