Documentation
¶
Overview ¶
Package xtag provides tags for primitive types.
Index ¶
- func BoolSliceSpec() nomix.Spec
- func BoolSpec() nomix.Spec
- func ByteSliceSpec() nomix.Spec
- func Float64SliceSpec() nomix.Spec
- func Float64Spec() nomix.Spec
- func Int64SliceSpec() nomix.Spec
- func Int64Spec() nomix.Spec
- func IntSliceSpec() nomix.Spec
- func IntSpec() nomix.Spec
- func JSONSpec() nomix.Spec
- func RegisterAll(reg *nomix.Registry)
- func StringSliceSpec() nomix.Spec
- func StringSpec() nomix.Spec
- func TimeSliceSpec() nomix.Spec
- func TimeSpec() nomix.Spec
- type Bool
- type BoolSlice
- type ByteSlice
- type Float64
- type Float64Slice
- type Int
- type Int64
- type Int64Slice
- type IntSlice
- type JSON
- type String
- type StringSlice
- type Time
- type TimeSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolSliceSpec ¶
BoolSliceSpec returns a nomix.Spec for BoolSlice type.
func ByteSliceSpec ¶
ByteSliceSpec returns a nomix.Spec for ByteSlice type.
func Float64SliceSpec ¶
Float64SliceSpec returns a nomix.Spec for Float64Slice type.
func Int64SliceSpec ¶
Int64SliceSpec returns a nomix.Spec for Int64Slice type.
func IntSliceSpec ¶
IntSliceSpec returns a nomix.Spec for IntSlice type.
func RegisterAll ¶
RegisterAll registers all nomix.Spec the package provides in the given nomix.Registry and associates types with them.
func StringSliceSpec ¶
StringSliceSpec returns a nomix.Spec for StringSlice type.
func TimeSliceSpec ¶
TimeSliceSpec returns a nomix.Spec for TimeSlice type.
Types ¶
type Bool ¶
Bool is a tag representing a single boolean value.
func CreateBool ¶
CreateBool casts the given value to bool. Returns the Bool instance with the given name and nil error on success. Returns nil and nomix.ErrInvType if the value is not the bool type.
type BoolSlice ¶
BoolSlice is a tag representing multiple boolean values.
func CreateBoolSlice ¶
CreateBoolSlice casts the value to []bool. Returns the BoolSlice instance with the given name and nil error on success. Returns nil and nomix.ErrInvType if the value is the []bool type.
type ByteSlice ¶
ByteSlice is a tag for a slice of bytes.
func CreateByteSlice ¶
CreateByteSlice casts the value to []byte. Returns the ByteSlice instance with the given name and nil error on success. Returns nil and nomix.ErrInvType if the value is not the []byte type.
type Float64 ¶
Float64 is a tag representing a single float64 value.
func CreateFloat64 ¶
CreateFloat64 casts the value to float64. Returns the Float64 instance with the given name and nil error if the value is a byte, int, int8, int16, int32, int64, float32, or float64. Returns nil and nomix.ErrInvType if the value's type is not a supported numeric type.
NOTE: For int64 values outside ±2^53 range, the result is undefined.
func NewFloat64 ¶
NewFloat64 returns a new instance of Float64.
type Float64Slice ¶
Float64Slice is a tag representing multiple boolean values.
func CreateFloat64Slice ¶
CreateFloat64Slice casts the value to []float64. Returns the Float64Slice instance with the given name and nil error if the value is a []int, []int8, []int16, []int32, []int64, []float32, or []float64. Returns nil and nomix.ErrInvType if the value's type is not a supported numeric slice type.
NOTE: For values outside ±2^53 range, the function will return an error.
func NewFloat64Slice ¶
func NewFloat64Slice(name string, val ...float64) *Float64Slice
NewFloat64Slice returns a new instance of Float64Slice.
type Int ¶
Int is a tag representing a single integer value.
func CreateInt ¶
CreateInt casts the value to int. Returns the Int instance with the given type and nil error on success. Returns nil and nomix.ErrInvType if the value is not the int type.
type Int64 ¶
Int64 is a tag representing a single int64 value.
func CreateInt64 ¶
CreateInt64 casts the value to int64. Returns the Int64 instance with the given name and nil error if the value is a byte, int, int8, int16, int32, or int64. Returns nil and nomix.ErrInvType if the value's type is not a supported numeric type.
type Int64Slice ¶
Int64Slice is a tag representing multiple int64 values.
func CreateInt64Slice ¶
CreateInt64Slice casts the value to []int64. Returns the Int64Slice instance with the given name and nil error if the value is a []int, []int8, []int16, []int32, or []int64. Returns nil and nomix.ErrInvType if the value's type is not a supported numeric slice type.
func NewInt64Slice ¶
func NewInt64Slice(name string, val ...int64) *Int64Slice
NewInt64Slice returns a new instance of Int64Slice.
type IntSlice ¶
IntSlice is a tag for a slice of int values.
func CreateIntSlice ¶
CreateIntSlice casts the value to []int. Returns the IntSlice instance with the given name and nil error on success. Returns nil and [ErrInvType] if the value is not []int type.
type JSON ¶
JSON is a tag for a json.RawMessage value.
func CreateJSON ¶
CreateJSON casts the value to json.RawMessage. Returns the JSON with the specified name and nil error if the value is a valid JSON represented as json.RawMessage, []byte or string. Returns nil and error if the value's type is not a supported type or the value is not a valid JSON.
type String ¶
String is a tag for a slice of strings.
func CreateString ¶
CreateString casts the value to a string. Returns the String instance with the given name and nil error on success. Returns nil and nomix.ErrInvType if the value is not the string type.
type StringSlice ¶
StringSlice is a tag for a slice of strings.
func CreateStringSlice ¶
CreateStringSlice casts the value to []string. Returns the StringSlice instance with the given name and nil error on success. Returns nil and [ErrInvType] if the value is not the []string type.
func NewStringSlice ¶
func NewStringSlice(name string, val ...string) *StringSlice
NewStringSlice returns a new instance of StringSlice.
type Time ¶
Time is a tag representing a single time.Time value.
func CreateTime ¶
CreateTime casts the value to time.Time, or when the value is a string, it parses it as time.RFC3339Nano time. Returns the Time instance with the given name and nil error on success. Returns nil and error if the value's type is not a supported type or the value is not a valid time representation.
func ParseTime ¶
ParseTime parses a string representation of time.Time. Returns the time and nil error if the value is a valid time representation. Returns zero value time and nomix.ErrInvFormat if the value is not a valid time representation.
To support string zero time values, use the [WithZeroTime] option.
type TimeSlice ¶
TimeSlice is a tag for a slice of time.Time values.
func CreateTimeSlice ¶
CreateTimeSlice casts the value to []time.Time, or when the value is a []string, it parses its elements as time.RFC3339Nano time. Returns the TimeSlice instance with the given name and nil error on success. Returns nil and error if the value's type is not a supported type or the value is not a valid time representation.