Documentation
¶
Index ¶
- func EmbeddedConfig() embed.FS
- func SetGlobal(updateFns ...func(config *Config))
- type ArrayConfig
- type BoolConfig
- type BoolFromNullConfig
- type BoolFromNumberAlg
- type BoolFromNumbersConfig
- type BoolFromStringsConfig
- type Config
- type DateConfig
- type DateFromNullConfig
- type DateFromNumbersConfig
- type DateFromStringsConfig
- type DateTimezoneConfig
- type FlexKeysConfig
- type NumberConfig
- type NumberFromBoolsConfig
- type NumberFromNullConfig
- type NumberFromStringsConfig
- type RoundingAlg
- type Section
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmbeddedConfig ¶
EmbeddedConfig returns the embedded config filesystem for external packages to access.
Types ¶
type ArrayConfig ¶
type BoolConfig ¶
type BoolConfig struct {
Section
FallbackValue maybe.Bool `toml:"FallbackValue"`
FromStrings *BoolFromStringsConfig `toml:"FromStrings"`
FromNumbers *BoolFromNumbersConfig `toml:"FromNumbers"`
FromNull *BoolFromNullConfig `toml:"FromNull"`
}
type BoolFromNullConfig ¶
type BoolFromNumberAlg ¶
type BoolFromNumberAlg uint8
BoolFromNumberAlg specifies the algorithm of how parsing Number->Bool is done.
const ( // BoolFromNumberUndefined is the undefined value. BoolFromNumberUndefined BoolFromNumberAlg = 0 // BoolFromNumberBinary is the "1/0" parser. 1 is true, 0 is false. // Other numbers are considered "non-parsed" (fallback value or Red result). BoolFromNumberBinary BoolFromNumberAlg = 1 << (iota - 1) // 1 (001) // BoolFromNumberPositiveNegative is the "<=0 vs >0" parser. // Positive numbers are true. Negative numbers And zero are false. BoolFromNumberPositiveNegative // 2 (010) // BoolFromNumberSignOfOne is the "-1/1" parser. // -1 means false, 1 means true. Other numbers are considered "non-parsed" (fallback value or Red result). BoolFromNumberSignOfOne // 4 (100) )
func ListAvailableBoolFromNumberAlgs ¶
func ListAvailableBoolFromNumberAlgs() []BoolFromNumberAlg
ListAvailableBoolFromNumberAlgs lists all available values of BoolFromNumberAlg.
func (*BoolFromNumberAlg) DefaultValue ¶
func (*BoolFromNumberAlg) DefaultValue() BoolFromNumberAlg
func (*BoolFromNumberAlg) MarshalText ¶
func (b *BoolFromNumberAlg) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for BoolFromNumberAlg. It converts an enum value into its string representation.
func (*BoolFromNumberAlg) String ¶
func (b *BoolFromNumberAlg) String() string
String stringifies the value of BoolFromNumberAlg.
func (*BoolFromNumberAlg) UnmarshalText ¶
func (b *BoolFromNumberAlg) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for BoolFromNumberAlg. It converts a string (e.g., "sign_of_one") into the corresponding enum value.
type BoolFromNumbersConfig ¶
type BoolFromNumbersConfig struct {
Section
CustomParseFunc BoolFromNumberAlg `toml:"CustomParseFunc"`
}
type BoolFromStringsConfig ¶
type BoolFromStringsConfig struct {
Section
// TODO(github.com/d3rty/json/issues/3) precache customListForTrue + CaseInsensitive (so we don't do lower of the list each time)
CustomListForTrue []string `toml:"CustomListForTrue"`
CustomListForFalse []string `toml:"CustomListForFalse"`
CaseInsensitive bool `toml:"CaseInsensitive"`
RespectFromNumbersLogic bool `toml:"RespectFromNumbersLogic"`
}
type Config ¶
type Config struct {
Section
Bool *BoolConfig `toml:"Bool"`
Number *NumberConfig `toml:"Number"`
Date *DateConfig `toml:"Date"`
Array *ArrayConfig `toml:"Array"`
FlexKeys *FlexKeysConfig `toml:"FlexKeys"`
}
Config holds global settings for dirty unmarshalling.
func Default ¶
func Default() *Config
Default returns a copy of the loaded default config (default.toml).
func Global ¶
func Global() *Config
Global returns a copy of the global configuration. The returned copy is a clone. Modifying of it doesn't affect the original config.
func (*Config) ResetToDefault ¶
func (cfg *Config) ResetToDefault()
ResetToDefault resets config to the default state.
func (*Config) ResetToEmpty ¶
func (cfg *Config) ResetToEmpty()
ResetToEmpty resets config to its clean state (clean config).
type DateConfig ¶
type DateConfig struct {
Section
Timezone *DateTimezoneConfig `toml:"Timezone"`
FromNumbers *DateFromNumbersConfig `toml:"FromNumbers"`
FromStrings *DateFromStringsConfig `toml:"FromStrings"`
FromNull *DateFromNullConfig `toml:"FromNull"`
}
type DateFromNullConfig ¶
type DateFromNullConfig struct {
Section
}
type DateFromNumbersConfig ¶
type DateFromStringsConfig ¶
type DateTimezoneConfig ¶
type FlexKeysConfig ¶
type NumberConfig ¶
type NumberConfig struct {
Section
FromStrings *NumberFromStringsConfig `toml:"FromStrings"`
FromBools *NumberFromBoolsConfig `toml:"FromBools"`
FromNull *NumberFromNullConfig `toml:"FromNull"`
}
type NumberFromBoolsConfig ¶
type NumberFromBoolsConfig struct {
Section
}
type NumberFromNullConfig ¶
type NumberFromNullConfig struct {
Section
}
type NumberFromStringsConfig ¶
type NumberFromStringsConfig struct {
Section
SpacingAllowed bool `toml:"SpacingAllowed"`
ExponentNotationAllowed bool `toml:"ExponentNotationAllowed"`
CommasAllowed bool `toml:"CommasAllowed"`
RoundingAlgorithm RoundingAlg `toml:"RoundingAlgorithm"`
}
type RoundingAlg ¶
type RoundingAlg uint8
RoundingAlg specifies the algorithm of how parsing Number->Bool is done.
const ( // RoundingAlgUndefined is the undefined value. RoundingAlgUndefined RoundingAlg = 0 // RoundingAlgNone means integers can't be parsed from floors with non-zero decimals. RoundingAlgNone RoundingAlg = 1 << (iota - 1) // 1 (001) // RoundingAlgFloor means it uses math.Floor() when parsing integers from floats. RoundingAlgFloor // 2 (010) // RoundingAlgRound means it uses math.Round() when parsing integers from floats. RoundingAlgRound // 4 (100) )
func ListAvailableRoundingAlgs ¶
func ListAvailableRoundingAlgs() []RoundingAlg
ListAvailableRoundingAlgs lists all available values of RoundingAlg.
func (*RoundingAlg) DefaultValue ¶
func (*RoundingAlg) DefaultValue() RoundingAlg
func (*RoundingAlg) MarshalText ¶
func (b *RoundingAlg) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for RoundingAlg. It converts an enum value into its string representation.
func (*RoundingAlg) String ¶
func (b *RoundingAlg) String() string
String stringifies the value of RoundingAlg.
func (*RoundingAlg) UnmarshalText ¶
func (b *RoundingAlg) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for RoundingAlg. It converts a string (e.g., "floor") into the corresponding enum value.
type Section ¶
type Section struct {
Disabled bool `toml:"Disabled"`
}
Section is a config section (toml table). Section is considered disabled if Disabled=true or full its parent is nil (see cfg.init()).
func (Section) IsDisabled ¶
IsDisabled return true if its `Disabled:true` was set in the toml.