Documentation ¶
Index ¶
- func Init(obj interface{})
- type Converter
- func (conv *Converter) Keys() []string
- func (conv *Converter) ToJSON() (string, error)
- func (conv *Converter) ToJSONIndent(prefix, indent string) (string, error)
- func (conv *Converter) ToMap() map[string]interface{}
- func (conv *Converter) ToXML() (string, error)
- func (conv *Converter) ToXMLIndent(prefix, indent string) (string, error)
- func (conv *Converter) ToYAML() (string, error)
- func (conv *Converter) Values() []interface{}
- type Default
- type Hasher
- type NonComparable
- type PreventUnkeyed
- type Stringer
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
Converter provides various marshalling methods to an embedding struct.
func (*Converter) ToJSONIndent ¶
ToJSONIndent is like ToJSON but applies Indent to format the output. Each JSON element in the output will begin on a new line beginning with prefix followed by one or more copies of indent according to the indentation nesting.
func (*Converter) ToXMLIndent ¶
ToXMLIndent works like ToXML, but each XML element begins on a new indented line that starts with prefix and is followed by one or more copies of indent according to the nesting depth.
type Default ¶
type Default struct{}
Default adds default initialization to an embedding struct fields. Note that it applies to exported fields only. No public methods exposed for this trait.
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher provides unique hash generators to an embedding struct.
func (*Hasher) HashCode32 ¶
HashCode32 generates a unique uint32 hash of an embedding struct.
func (*Hasher) HashCode64 ¶
HashCode64 generates a unique uint64 hash of an embedding struct.
type NonComparable ¶
type NonComparable struct {
// contains filtered or unexported fields
}
NonComparable is a struct to embed when you need to prevent structs comparison.
NonComparable trait doesn't require the `traits.Init` call.
type PreventUnkeyed ¶
type PreventUnkeyed struct {
// contains filtered or unexported fields
}
PreventUnkeyed is a struct to embed when you need to forbid unkeyed literals usage.
PreventUnkeyed trait doesn't require the `traits.Init` call.
type Stringer ¶
type Stringer struct {
// contains filtered or unexported fields
}
Stringer implements the `fmt.Stringer` interface. Adds the String method to an embedding struct.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator adds the Validate function to an embedding struct, which can be used to validate structure fields by tags.
List of available validators for struct fields: "email" "url" "dialstring" "requrl" "requri" "alpha" "utfletter" "alphanum" "utfletternum" "numeric" "utfnumeric" "utfdigit" "hexadecimal" "hexcolor" "rgbcolor" "lowercase" "uppercase" "int" "float" "null" "uuid" "uuidv3" "uuidv4" "uuidv5" "creditcard" "isbn10" "isbn13" "json" "multibyte" "ascii" "printableascii" "fullwidth" "halfwidth" "variablewidth" "base64" "datauri" "ip" "port" "ipv4" "ipv6" "dns" "host" "mac" "latitude" "longitude" "ssn" "semver" "rfc3339" "rfc3339WithoutZone" "ISO3166Alpha2" "ISO3166Alpha3"
Example:
type Example struct { Str string `valid:"numeric"` Email string `valid:"email"` }