xtag

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package xtag provides tags for primitive types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolSliceSpec

func BoolSliceSpec() nomix.Spec

BoolSliceSpec returns a nomix.Spec for BoolSlice type.

func BoolSpec

func BoolSpec() nomix.Spec

BoolSpec returns a nomix.Spec for Bool type.

func ByteSliceSpec

func ByteSliceSpec() nomix.Spec

ByteSliceSpec returns a nomix.Spec for ByteSlice type.

func Float64SliceSpec

func Float64SliceSpec() nomix.Spec

Float64SliceSpec returns a nomix.Spec for Float64Slice type.

func Float64Spec

func Float64Spec() nomix.Spec

Float64Spec returns a nomix.Spec for Float64 type.

func Int64SliceSpec

func Int64SliceSpec() nomix.Spec

Int64SliceSpec returns a nomix.Spec for Int64Slice type.

func Int64Spec

func Int64Spec() nomix.Spec

Int64Spec returns a nomix.Spec for Int64 type.

func IntSliceSpec

func IntSliceSpec() nomix.Spec

IntSliceSpec returns a nomix.Spec for IntSlice type.

func IntSpec

func IntSpec() nomix.Spec

IntSpec returns a nomix.Spec for Int type.

func JSONSpec

func JSONSpec() nomix.Spec

JSONSpec returns a nomix.Spec for JSON type.

func RegisterAll

func RegisterAll(reg *nomix.Registry)

RegisterAll registers all nomix.Spec the package provides in the given nomix.Registry and associates types with them.

func StringSliceSpec

func StringSliceSpec() nomix.Spec

StringSliceSpec returns a nomix.Spec for StringSlice type.

func StringSpec

func StringSpec() nomix.Spec

StringSpec returns a nomix.Spec for String type.

func TimeSliceSpec

func TimeSliceSpec() nomix.Spec

TimeSliceSpec returns a nomix.Spec for TimeSlice type.

func TimeSpec

func TimeSpec() nomix.Spec

TimeSpec returns a nomix.Spec for Time type.

Types

type Bool

type Bool = nomix.Single[bool]

Bool is a tag representing a single boolean value.

func CreateBool

func CreateBool(name string, val any, _ ...nomix.Option) (*Bool, error)

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.

func NewBool

func NewBool(name string, val bool) *Bool

NewBool returns a new instance of Bool.

func ParseBool

func ParseBool(name, val string, _ ...nomix.Option) (*Bool, error)

ParseBool parses string representation of the boolean tag.

type BoolSlice

type BoolSlice = nomix.Slice[bool]

BoolSlice is a tag representing multiple boolean values.

func CreateBoolSlice

func CreateBoolSlice(
	name string,
	val any,
	_ ...nomix.Option,
) (*BoolSlice, error)

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.

func NewBoolSlice

func NewBoolSlice(name string, val ...bool) *BoolSlice

NewBoolSlice returns a new instance of BoolSlice.

type ByteSlice

type ByteSlice = nomix.Slice[byte]

ByteSlice is a tag for a slice of bytes.

func CreateByteSlice

func CreateByteSlice(
	name string,
	val any,
	_ ...nomix.Option,
) (*ByteSlice, error)

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.

func NewByteSlice

func NewByteSlice(name string, val ...byte) *ByteSlice

NewByteSlice returns a new instance of ByteSlice.

type Float64

type Float64 = nomix.Single[float64]

Float64 is a tag representing a single float64 value.

func CreateFloat64

func CreateFloat64(name string, val any, _ ...nomix.Option) (*Float64, error)

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

func NewFloat64(name string, val float64) *Float64

NewFloat64 returns a new instance of Float64.

func ParseFloat64

func ParseFloat64(name, v string, _ ...nomix.Option) (*Float64, error)

ParseFloat64 parses string representation of the 64-bit floating point tag.

type Float64Slice

type Float64Slice = nomix.Slice[float64]

Float64Slice is a tag representing multiple boolean values.

func CreateFloat64Slice

func CreateFloat64Slice(
	name string,
	val any,
	_ ...nomix.Option,
) (*Float64Slice, error)

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

type Int = nomix.Single[int]

Int is a tag representing a single integer value.

func CreateInt

func CreateInt(name string, val any, _ ...nomix.Option) (*Int, error)

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.

func NewInt

func NewInt(name string, val int) *Int

NewInt returns a new instance of Int.

func ParseInt

func ParseInt(name, val string, opts ...nomix.Option) (*Int, error)

ParseInt parses string representation of the integer tag.

type Int64

type Int64 = nomix.Single[int64]

Int64 is a tag representing a single int64 value.

func CreateInt64

func CreateInt64(name string, val any, _ ...nomix.Option) (*Int64, error)

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.

func NewInt64

func NewInt64(name string, val int64) *Int64

NewInt64 returns a new instance of Int64.

func ParseInt64

func ParseInt64(name, v string, opts ...nomix.Option) (*Int64, error)

ParseInt64 parses string representation of the 64-bit integer tag.

type Int64Slice

type Int64Slice = nomix.Slice[int64]

Int64Slice is a tag representing multiple int64 values.

func CreateInt64Slice

func CreateInt64Slice(
	name string,
	val any,
	_ ...nomix.Option,
) (*Int64Slice, error)

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

type IntSlice = nomix.Slice[int]

IntSlice is a tag for a slice of int values.

func CreateIntSlice

func CreateIntSlice(name string, val any, _ ...nomix.Option) (*IntSlice, error)

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.

func NewIntSlice

func NewIntSlice(name string, val ...int) *IntSlice

NewIntSlice returns a new instance of IntSlice.

type JSON

type JSON = nomix.Slice[byte]

JSON is a tag for a json.RawMessage value.

func CreateJSON

func CreateJSON(name string, val any, _ ...nomix.Option) (*JSON, error)

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.

func NewJSON

func NewJSON(name string, v json.RawMessage) *JSON

NewJSON returns a new instance of JSON.

func ParseJSON

func ParseJSON(name, v string, _ ...nomix.Option) (*JSON, error)

ParseJSON parses string representation of the raw JSON tag.

type String

type String = nomix.Single[string]

String is a tag for a slice of strings.

func CreateString

func CreateString(name string, val any, _ ...nomix.Option) (*String, error)

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.

func NewString

func NewString(name, val string) *String

NewString returns a new instance of String.

type StringSlice

type StringSlice = nomix.Slice[string]

StringSlice is a tag for a slice of strings.

func CreateStringSlice

func CreateStringSlice(name string, val any, _ ...nomix.Option) (*StringSlice, error)

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

type Time = nomix.Single[time.Time]

Time is a tag representing a single time.Time value.

func CreateTime

func CreateTime(name string, val any, opts ...nomix.Option) (*Time, error)

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 NewTime

func NewTime(name string, val time.Time) *Time

NewTime returns a new instance of Time.

func ParseTime

func ParseTime(name, val string, opts ...nomix.Option) (*Time, error)

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

type TimeSlice = nomix.Slice[time.Time]

TimeSlice is a tag for a slice of time.Time values.

func CreateTimeSlice

func CreateTimeSlice(
	name string,
	val any,
	opts ...nomix.Option,
) (*TimeSlice, error)

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.

func NewTimeSlice

func NewTimeSlice(name string, val ...time.Time) *TimeSlice

NewTimeSlice returns a new instance of TimeSlice.

Jump to

Keyboard shortcuts

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