Documentation ¶
Index ¶
- Variables
- func AddDateTimeFormat(format string)
- func BoolParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func DateParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func DateTimeParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func DecimalParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func DecimalPercentParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func DeleteKV(c map[string]interface{}, key string) (deleted bool)
- func EmailParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func GetKV(c map[string]interface{}, key string) (k string, v interface{})
- func HtmlParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func KebabOptionParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func KebabParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func LanguageParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func LanguageTagParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func NumberParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func NumberPercentParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func ParseTimeStructure(input string) (parsed time.Time, err error)
- func PathParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func RelativeUrlParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func SetKV(c map[string]interface{}, key string, value interface{}) (err error)
- func StringMapParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func StringOptionParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func StringParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func TimeParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func TimeStructParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func ToKebab(input string) (kebab string)
- func UrlParser(spec *Field, input interface{}) (parsed interface{}, err error)
- func UuidParser(spec *Field, input interface{}) (parsed interface{}, err error)
- type Context
- func (c Context) Apply(contexts ...Context)
- func (c Context) ApplySpecific(contexts ...Context)
- func (c Context) AsDeepKeyed() (ctx Context)
- func (c Context) AsJSON() (data []byte, err error)
- func (c Context) AsMap() (out map[string]interface{})
- func (c Context) AsMapStrings() (out map[string]string)
- func (c Context) AsOsEnviron() (out []string)
- func (c Context) AsTOML() (data []byte, err error)
- func (c Context) AsYAML() (data []byte, err error)
- func (c Context) Bool(key string, def bool) bool
- func (c Context) Boolean(key string) (value, ok bool)
- func (c Context) Bytes(key string, def []byte) []byte
- func (c Context) CamelizeKeys()
- func (c Context) Context(key string) (ctx Context)
- func (c Context) Copy() (ctx Context)
- func (c Context) DeepKeys() (keys []string)
- func (c Context) DefaultStrings(key string, def []string) []string
- func (c Context) Delete(key string) (deleted bool)
- func (c Context) DeleteKeys(keys ...string)
- func (c Context) Empty() (empty bool)
- func (c Context) FirstString(key string) (value string, ok bool)
- func (c Context) Float64(key string, def float64) float64
- func (c Context) Get(key string) (value interface{})
- func (c Context) GetKV(key string) (k string, v interface{})
- func (c Context) Has(key string) (present bool)
- func (c Context) HasExact(key string) (present bool)
- func (c Context) Int(key string, def int) int
- func (c Context) Int64(key string, def int64) int64
- func (c Context) KebabKeys()
- func (c Context) Keys() (keys []string)
- func (c Context) Len() (count int)
- func (c Context) LowerCamelizeKeys()
- func (c Context) PruneEmpty() (pruned Context)
- func (c Context) Select(keys ...string) (selected map[string]interface{})
- func (c Context) Set(key string, value interface{}) Context
- func (c Context) SetKV(key string, value interface{}) (err error)
- func (c Context) SetSpecific(key string, value interface{}) Context
- func (c Context) Slice(key string) (list []interface{}, ok bool)
- func (c Context) String(key, def string) string
- func (c Context) StringOrStrings(key string) (values []string)
- func (c Context) Strings(key string) (values []string)
- func (c Context) Uint(key string, def uint) uint
- func (c Context) Uint64(key string, def uint64) uint64
- func (c Context) ValueAsInt(key string, def int) int
- type Field
- type Fields
- func (f Fields) CategoryNames() (names []string)
- func (f Fields) Copy() (copied Fields)
- func (f Fields) Init(printer *message.Printer, parsers Parsers)
- func (f Fields) Keys() (keys []string)
- func (f Fields) Len() (count int)
- func (f Fields) Lookup(key string) (field *Field, ok bool)
- func (f Fields) SortedKeys() (keys []string)
- func (f Fields) TabCategoryFields(tab, category string, ignored ...string) (fields Fields)
- func (f Fields) TabCategoryNames(tab string) (keys []string)
- func (f Fields) TabFields(tab string) (fields Fields)
- func (f Fields) TabNames() (names []string)
- type Parser
- type Parsers
Constants ¶
This section is empty.
Variables ¶
var ( DateLayout = "Jan 02, 2006" TimeLayout = "15:04 -0700" DateTimeLayout = "2006-01-02 15:04 MST" )
var ( DefaultParsers = Parsers{ "bool": BoolParser, "html": HtmlParser, "string": StringParser, "string-map": StringMapParser, "string-option": StringOptionParser, "number": NumberParser, "number-percent": NumberPercentParser, "decimal": DecimalParser, "decimal-percent": DecimalPercentParser, "email": EmailParser, "path": PathParser, "url": UrlParser, "relative-url": RelativeUrlParser, "time": TimeParser, "date": DateParser, "date-time": DateTimeParser, "time-struct": TimeStructParser, "language": LanguageParser, "language-tag": LanguageTagParser, "kebab": KebabParser, "kebab-option": KebabOptionParser, "uuid": UuidParser, } )
Functions ¶
func AddDateTimeFormat ¶ added in v0.5.0
func AddDateTimeFormat(format string)
func BoolParser ¶ added in v0.5.0
func DateParser ¶ added in v0.5.0
func DateTimeParser ¶ added in v0.5.0
func DecimalParser ¶ added in v0.5.0
func DecimalPercentParser ¶ added in v0.5.0
func EmailParser ¶ added in v0.5.0
func GetKV ¶ added in v0.4.0
GetKV looks for the key as given first and if not found looks for CamelCased, kebab-case and snake_cased variations; returning the actual key found and the generic value; returns an empty key and nil value if nothing found at all
func HtmlParser ¶ added in v0.5.0
func KebabOptionParser ¶ added in v0.5.0
func KebabParser ¶ added in v0.5.0
func LanguageParser ¶ added in v0.5.0
func LanguageTagParser ¶ added in v0.5.0
func NumberParser ¶ added in v0.5.0
func NumberPercentParser ¶ added in v0.5.0
func ParseTimeStructure ¶ added in v0.5.0
func PathParser ¶ added in v0.5.0
func RelativeUrlParser ¶ added in v0.5.0
func StringMapParser ¶ added in v0.5.0
func StringOptionParser ¶ added in v0.5.0
func StringParser ¶ added in v0.5.0
func TimeParser ¶ added in v0.5.0
func TimeStructParser ¶ added in v0.5.0
func UuidParser ¶ added in v0.5.0
Types ¶
type Context ¶
type Context map[string]interface{}
Context is a wrapper around a map[string]interface{} structure which is used throughout Go-Enjin for parsing configurations and contents.
func NewFromMap ¶
NewFromMap casts an existing map[string]interface{} as a Context
func NewFromOsEnviron ¶
NewFromOsEnviron constructs a new Context from os.Environ() string K=V slices
func (Context) ApplySpecific ¶ added in v0.2.2
ApplySpecific takes a list of contexts and merges their contents into this one, keeping the keys specifically
func (Context) AsDeepKeyed ¶ added in v0.5.0
AsDeepKeyed returns a deep-key flattened version of this context For example:
map[string]interface{}{"one": map[string]interface{}{"two": "deep"}}
becomes:
map[string]interface{}{".one.two": "deep"}
func (Context) AsMap ¶
AsMap returns this Context, shallowly copied, as a new map[string]interface{} instance.
func (Context) AsMapStrings ¶
AsMapStrings returns this Context as a transformed map[string]string structure, where each key's value is checked and if it's a string, use it as-is and if it's anything else, run it through fmt.Sprintf("%v") to make it a string.
func (Context) AsOsEnviron ¶
AsOsEnviron returns this Context as a transformed []string slice where each key is converted to SCREAMING_SNAKE_CASE and the value is converted to a string (similarly to AsMapStrings) and the key/value pair is concatenated into a single "K=V" string and appended to the output slice, sorted by key in natural order, suitable for use in os.Environ cases.
func (Context) Bytes ¶ added in v0.5.0
Bytes returns the key's value as a byte slice, returning the given default if not found or not actually a byte slice value.
func (Context) CamelizeKeys ¶
func (c Context) CamelizeKeys()
CamelizeKeys transforms all keys within the Context to be of CamelCased form
func (Context) Context ¶ added in v0.5.0
Context looks for the given key and if the value is of Context type, returns it
func (Context) DeepKeys ¶ added in v0.5.0
DeepKeys returns a list of .deep.keys for the entire context structure
func (Context) DefaultStrings ¶
DefaultStrings is a wrapper around Strings() and returns the given default list of strings if the key is not found
func (Context) Delete ¶
Delete deletes the given key from the Context and follows a similar key lookup process to Get() for finding the key to delete and will only delete the first matching key format (specific, Camel, kebab) found
func (Context) DeleteKeys ¶
DeleteKeys is a batch wrapper around Delete()
func (Context) FirstString ¶ added in v0.5.0
func (Context) GetKV ¶ added in v0.2.2
GetKV looks for the key as given first and if not found looks for CamelCased, kebab-case and snake_cased variations; returning the actual key found and the generic value; returns an empty key and nil value if nothing found at all
func (Context) HasExact ¶ added in v0.5.0
HasExact returns true if the specific Context key given exists and is not nil
func (Context) KebabKeys ¶ added in v0.4.0
func (c Context) KebabKeys()
KebabKeys transforms all keys within the Context to be of kebab-cased form
func (Context) Keys ¶
Keys returns a list of all the map keys in the Context, sorted in natural order for consistency
func (Context) LowerCamelizeKeys ¶ added in v0.2.2
func (c Context) LowerCamelizeKeys()
LowerCamelizeKeys transforms all keys within the Context to be of lowerCamelCased form
func (Context) PruneEmpty ¶ added in v0.5.0
func (Context) SetSpecific ¶
SetSpecific is like Set(), without CamelCasing the key
func (Context) String ¶
String returns the key's value as a string, returning the given default if not found or not actually a string value.
func (Context) StringOrStrings ¶
StringOrStrings returns the key's value as a list of strings and if the key's actual value is not a list of strings, return that as a list of one string
type Field ¶ added in v0.5.0
type Field struct { Key string `json:"key"` Tab string `json:"tab"` Label string `json:"label"` Format string `json:"format"` Category string `json:"category"` Input string `json:"input"` Weight int `json:"weight"` Required bool `json:"required,omitempty"` Step float64 `json:"step"` Minimum float64 `json:"minimum"` Maximum float64 `json:"maximum"` Placeholder string `json:"placeholder"` DefaultValue interface{} `json:"default-value"` ValueLabels map[string]string `json:"value-labels"` ValueOptions []string `json:"value-options"` LockNonEmpty bool `json:"lock-non-empty"` NoResetValue bool `json:"no-reset-value"` Printer *message.Printer `json:"-"` Parse Parser `json:"-"` }