Help us shape the future of Go! Take the 2026 Go Developer Survey

internal

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagName    = "name"
	TagUsage   = "usage"
	TagDefault = "default"
	TagShort   = "short"
	TagCount   = "count"
	TagSplit   = "split"
	TagSep     = "sep"

	TagNameIgnored = "-"
)

Variables

View Source
var (
	ErrStructConfig     = errors.New("StructConfig")
	ErrNotStruct        = errors.New("NotStruct")
	ErrNotStructPointer = errors.New("NotStructPointer")
)
View Source
var (
	// Result of conv as default value in ParsePair.
	ErrParseAsDefault = errors.New("ParseAsDefault")
)
View Source
var (
	// Skip conv and callback but no error in TryParse.
	ErrSkipParse = errors.New("SkipParse")
)

Functions

func Call

func Call(r Receptor, f StructField) error

Call calls the appropriate method of r for the field f.

func Errorf

func Errorf(format string, v ...any) error

func IsSupportedKind

func IsSupportedKind(k reflect.Kind) bool

func JoinErrors

func JoinErrors(err ...error) error

func ParseDuration added in v0.10.0

func ParseDuration(s string) (time.Duration, error)

func ParseFloat

func ParseFloat[T constraints.Float](s string) (T, error)

func ParseInt

func ParseInt[T constraints.Signed](s string) (T, error)

func ParseSlice added in v0.10.0

func ParseSlice[T any](s string, elemConv func(string) (T, error)) ([]T, error)

func ParseStringSlice added in v0.11.0

func ParseStringSlice(s string, split bool, sep string) ([]string, error)

func ParseTime added in v0.10.0

func ParseTime(s string) (time.Time, error)

func ParseUint

func ParseUint[T constraints.Unsigned](s string) (T, error)

func Switch

func Switch(r Receptor, f StructField) func(StructField) error

Switch chooses a method of r that corresponds to f.

func TryParse

func TryParse[S, T any](
	conv func(S) (T, error),
	callback func(S, T) error,
) func(S) error

Types

type AnyReceptor

type AnyReceptor interface {
	Any(StructField) error
}

type BoolReceptor

type BoolReceptor interface {
	Bool(StructField) error
}

type ConvFunc

type ConvFunc[T any] func(string) (T, error)

ConvFunc is a function that converts string into T.

func (ConvFunc[T]) Call

func (f ConvFunc[T]) Call(s string) (T, error)

Call calls self if not nil, otherwise returns the default value.

type Converter

type Converter interface {
	Bool(s string) (bool, error)
	Int(s string) (int, error)
	Int8(s string) (int8, error)
	Int16(s string) (int16, error)
	Int32(s string) (int32, error)
	Int64(s string) (int64, error)
	Uint(s string) (uint, error)
	Uint8(s string) (uint8, error)
	Uint16(s string) (uint16, error)
	Uint32(s string) (uint32, error)
	Uint64(s string) (uint64, error)
	Float32(s string) (float32, error)
	Float64(s string) (float64, error)
	String(s string) (string, error)
	BoolSlice(s string) ([]bool, error)
	IntSlice(s string) ([]int, error)
	Int32Slice(s string) ([]int32, error)
	Int64Slice(s string) ([]int64, error)
	UintSlice(s string) ([]uint, error)
	Float32Slice(s string) ([]float32, error)
	Float64Slice(s string) ([]float64, error)
	StringSlice(s string) ([]string, error)
	Duration(s string) (time.Duration, error)
	Time(s string) (time.Time, error)
	Count(s string) (int, error)
}

Converter is a set of string conversions.

type CountReceptor added in v0.10.0

type CountReceptor interface {
	Count(StructField) error
}

type DefaultConverter

type DefaultConverter struct {
	BoolFunc         ConvFunc[bool]
	IntFunc          ConvFunc[int]
	Int8Func         ConvFunc[int8]
	Int16Func        ConvFunc[int16]
	Int32Func        ConvFunc[int32]
	Int64Func        ConvFunc[int64]
	UintFunc         ConvFunc[uint]
	Uint8Func        ConvFunc[uint8]
	Uint16Func       ConvFunc[uint16]
	Uint32Func       ConvFunc[uint32]
	Uint64Func       ConvFunc[uint64]
	Float32Func      ConvFunc[float32]
	Float64Func      ConvFunc[float64]
	StringFunc       ConvFunc[string]
	BoolSliceFunc    ConvFunc[[]bool]
	IntSliceFunc     ConvFunc[[]int]
	Int32SliceFunc   ConvFunc[[]int32]
	Int64SliceFunc   ConvFunc[[]int64]
	UintSliceFunc    ConvFunc[[]uint]
	Float32SliceFunc ConvFunc[[]float32]
	Float64SliceFunc ConvFunc[[]float64]
	StringSliceFunc  ConvFunc[[]string]
	DurationFunc     ConvFunc[time.Duration]
	TimeFunc         ConvFunc[time.Time]
	CountFunc        ConvFunc[int]
}

DefaultConverter implements Converter.

func NewConv

func NewConv() *DefaultConverter

func PFlagGetConverter

func PFlagGetConverter(fs *pflag.FlagSet) *DefaultConverter

func (DefaultConverter) Bool

func (c DefaultConverter) Bool(s string) (bool, error)

func (DefaultConverter) BoolSlice added in v0.10.0

func (c DefaultConverter) BoolSlice(s string) ([]bool, error)

func (DefaultConverter) Count added in v0.10.0

func (c DefaultConverter) Count(s string) (int, error)

func (DefaultConverter) Duration added in v0.10.0

func (c DefaultConverter) Duration(s string) (time.Duration, error)

func (DefaultConverter) Float32

func (c DefaultConverter) Float32(s string) (float32, error)

func (DefaultConverter) Float32Slice added in v0.10.0

func (c DefaultConverter) Float32Slice(s string) ([]float32, error)

func (DefaultConverter) Float64

func (c DefaultConverter) Float64(s string) (float64, error)

func (DefaultConverter) Float64Slice added in v0.10.0

func (c DefaultConverter) Float64Slice(s string) ([]float64, error)

func (DefaultConverter) Int

func (c DefaultConverter) Int(s string) (int, error)

func (DefaultConverter) Int8

func (c DefaultConverter) Int8(s string) (int8, error)

func (DefaultConverter) Int16

func (c DefaultConverter) Int16(s string) (int16, error)

func (DefaultConverter) Int32

func (c DefaultConverter) Int32(s string) (int32, error)

func (DefaultConverter) Int32Slice added in v0.10.0

func (c DefaultConverter) Int32Slice(s string) ([]int32, error)

func (DefaultConverter) Int64

func (c DefaultConverter) Int64(s string) (int64, error)

func (DefaultConverter) Int64Slice added in v0.10.0

func (c DefaultConverter) Int64Slice(s string) ([]int64, error)

func (DefaultConverter) IntSlice added in v0.10.0

func (c DefaultConverter) IntSlice(s string) ([]int, error)

func (DefaultConverter) String

func (c DefaultConverter) String(s string) (string, error)

func (DefaultConverter) StringSlice added in v0.10.0

func (c DefaultConverter) StringSlice(s string) ([]string, error)

func (DefaultConverter) Time added in v0.10.0

func (c DefaultConverter) Time(s string) (time.Time, error)

func (DefaultConverter) Uint

func (c DefaultConverter) Uint(s string) (uint, error)

func (DefaultConverter) Uint8

func (c DefaultConverter) Uint8(s string) (uint8, error)

func (DefaultConverter) Uint16

func (c DefaultConverter) Uint16(s string) (uint16, error)

func (DefaultConverter) Uint32

func (c DefaultConverter) Uint32(s string) (uint32, error)

func (DefaultConverter) Uint64

func (c DefaultConverter) Uint64(s string) (uint64, error)

func (DefaultConverter) UintSlice added in v0.10.0

func (c DefaultConverter) UintSlice(s string) ([]uint, error)

type DefaultTypedReceptor

type DefaultTypedReceptor struct {
	BoolFunc         TypedReceptorFunc[bool]
	IntFunc          TypedReceptorFunc[int]
	Int8Func         TypedReceptorFunc[int8]
	Int16Func        TypedReceptorFunc[int16]
	Int32Func        TypedReceptorFunc[int32]
	Int64Func        TypedReceptorFunc[int64]
	UintFunc         TypedReceptorFunc[uint]
	Uint8Func        TypedReceptorFunc[uint8]
	Uint16Func       TypedReceptorFunc[uint16]
	Uint32Func       TypedReceptorFunc[uint32]
	Uint64Func       TypedReceptorFunc[uint64]
	Float32Func      TypedReceptorFunc[float32]
	Float64Func      TypedReceptorFunc[float64]
	StringFunc       TypedReceptorFunc[string]
	BoolSliceFunc    TypedReceptorFunc[[]bool]
	IntSliceFunc     TypedReceptorFunc[[]int]
	Int32SliceFunc   TypedReceptorFunc[[]int32]
	Int64SliceFunc   TypedReceptorFunc[[]int64]
	UintSliceFunc    TypedReceptorFunc[[]uint]
	Float32SliceFunc TypedReceptorFunc[[]float32]
	Float64SliceFunc TypedReceptorFunc[[]float64]
	StringSliceFunc  TypedReceptorFunc[[]string]
	DurationFunc     TypedReceptorFunc[time.Duration]
	TimeFunc         TypedReceptorFunc[time.Time]
	CountFunc        TypedReceptorFunc[int]
	AnyFunc          TypedReceptorFunc[string]
}

DefaultTypedReceptor implements TypedReceptor.

func FlagSetTypedReceptor

func FlagSetTypedReceptor(
	boolFunc FlagSetFunc[bool],
	intFunc FlagSetFunc[int],
	int8Func FlagSetFunc[int8],
	int16Func FlagSetFunc[int16],
	int32Func FlagSetFunc[int32],
	int64Func FlagSetFunc[int64],
	uintFunc FlagSetFunc[uint],
	uint8Func FlagSetFunc[uint8],
	uint16Func FlagSetFunc[uint16],
	uint32Func FlagSetFunc[uint32],
	uint64Func FlagSetFunc[uint64],
	float32Func FlagSetFunc[float32],
	float64Func FlagSetFunc[float64],
	stringFunc FlagSetFunc[string],
	boolSliceFunc FlagSetFunc[[]bool],
	intSliceFunc FlagSetFunc[[]int],
	int32SliceFunc FlagSetFunc[[]int32],
	int64SliceFunc FlagSetFunc[[]int64],
	uintSliceFunc FlagSetFunc[[]uint],
	float32SliceFunc FlagSetFunc[[]float32],
	float64SliceFunc FlagSetFunc[[]float64],
	stringSliceFunc FlagSetFunc[[]string],
	durationFunc FlagSetFunc[time.Duration],
	timeFunc FlagSetFunc[time.Time],
	countFunc FlagSetFunc[int],
	anyFunc FlagSetFunc[string],
) *DefaultTypedReceptor

func PFlagSetTypeReceptor

func PFlagSetTypeReceptor(fs *pflag.FlagSet) *DefaultTypedReceptor

func SetTypedReceptor

func SetTypedReceptor(
	ptr any,
	anyCallback func(StructField, string, func() reflect.Value) error,
	onSet func(StructField, any),
) (*DefaultTypedReceptor, error)

func (DefaultTypedReceptor) Any

func (DefaultTypedReceptor) Bool

func (DefaultTypedReceptor) BoolSlice added in v0.10.0

func (r DefaultTypedReceptor) BoolSlice(s StructField, v []bool) error

func (DefaultTypedReceptor) Count added in v0.10.0

func (r DefaultTypedReceptor) Count(s StructField, v int) error

func (DefaultTypedReceptor) Duration added in v0.10.0

func (DefaultTypedReceptor) Float32

func (DefaultTypedReceptor) Float32Slice added in v0.10.0

func (r DefaultTypedReceptor) Float32Slice(s StructField, v []float32) error

func (DefaultTypedReceptor) Float64

func (DefaultTypedReceptor) Float64Slice added in v0.10.0

func (r DefaultTypedReceptor) Float64Slice(s StructField, v []float64) error

func (DefaultTypedReceptor) Int

func (DefaultTypedReceptor) Int8

func (DefaultTypedReceptor) Int16

func (DefaultTypedReceptor) Int32

func (DefaultTypedReceptor) Int32Slice added in v0.10.0

func (r DefaultTypedReceptor) Int32Slice(s StructField, v []int32) error

func (DefaultTypedReceptor) Int64

func (DefaultTypedReceptor) Int64Slice added in v0.10.0

func (r DefaultTypedReceptor) Int64Slice(s StructField, v []int64) error

func (DefaultTypedReceptor) IntSlice added in v0.10.0

func (r DefaultTypedReceptor) IntSlice(s StructField, v []int) error

func (DefaultTypedReceptor) String

func (DefaultTypedReceptor) StringSlice added in v0.10.0

func (r DefaultTypedReceptor) StringSlice(s StructField, v []string) error

func (DefaultTypedReceptor) Time added in v0.10.0

func (DefaultTypedReceptor) Uint

func (DefaultTypedReceptor) Uint8

func (DefaultTypedReceptor) Uint16

func (DefaultTypedReceptor) Uint32

func (DefaultTypedReceptor) Uint64

func (DefaultTypedReceptor) UintSlice added in v0.10.0

func (r DefaultTypedReceptor) UintSlice(s StructField, v []uint) error

type DurationReceptor added in v0.10.0

type DurationReceptor interface {
	Duration(StructField) error
}

type EnvVar

type EnvVar string

EnvVar is a environment variable.

func NewEnvVar

func NewEnvVar(name string) EnvVar

func (EnvVar) Get

func (v EnvVar) Get() (string, bool)

Get retrieves the value of the environment variable.

func (EnvVar) String

func (v EnvVar) String() string

String returns the name of the environment variable.

type FlagSetFunc

type FlagSetFunc[T any] func(name string, defaultValue T, usage string) error

FlagSetFunc defines a command-line flag.

func (FlagSetFunc[T]) SetFlag

func (f FlagSetFunc[T]) SetFlag(s StructField, v T) error

SetFlag defines a flag.

  • name: name tag value
  • default value: v
  • usage: usage tag value

type FloatReceptor

type FloatReceptor interface {
	Float32(StructField) error
	Float64(StructField) error
}

type IntReceptor

type IntReceptor interface {
	Int(StructField) error
	Int8(StructField) error
	Int16(StructField) error
	Int32(StructField) error
	Int64(StructField) error
}

type Merger

type Merger[T any] struct {
	// contains filtered or unexported fields
}

func NewMerger

func NewMerger[T any](
	anyCallback func(StructField, string, func() reflect.Value) error,
	anyEqual func(left, right any) (bool, error),
	prefix string,
	logger *slog.Logger,
) *Merger[T]

NewMerger returns a new Merger.

anyCallback parses "default" tag value and set it. anyEqual reports true if left equals right when kind of arguments are not supported. prefix adds a prefix to "default" tag name.

func (Merger[T]) Merge

func (m Merger[T]) Merge(left, right T) (T, error)

Merge values based on the 'default' tag values. For each field, if the right value is not the default, use it; if not, use the left value. If that is also the default, set the default value. Return this instance.

type PairsReceptor

type PairsReceptor struct {
	BoolPair         *ParsePair[bool]
	IntPair          *ParsePair[int]
	Int8Pair         *ParsePair[int8]
	Int16Pair        *ParsePair[int16]
	Int32Pair        *ParsePair[int32]
	Int64Pair        *ParsePair[int64]
	UintPair         *ParsePair[uint]
	Uint8Pair        *ParsePair[uint8]
	Uint16Pair       *ParsePair[uint16]
	Uint32Pair       *ParsePair[uint32]
	Uint64Pair       *ParsePair[uint64]
	Float32Pair      *ParsePair[float32]
	Float64Pair      *ParsePair[float64]
	StringPair       *ParsePair[string]
	BoolSlicePair    *ParsePair[[]bool]
	IntSlicePair     *ParsePair[[]int]
	Int32SlicePair   *ParsePair[[]int32]
	Int64SlicePair   *ParsePair[[]int64]
	UintSlicePair    *ParsePair[[]uint]
	Float32SlicePair *ParsePair[[]float32]
	Float64SlicePair *ParsePair[[]float64]
	StringSlicePair  *ParsePair[[]string]
	DurationPair     *ParsePair[time.Duration]
	TimePair         *ParsePair[time.Time]
	CountPair        *ParsePair[int]
	AnyPair          *ParsePair[string]
}

PairsReceptor is a set of ParsePair, implements Receptor.

func DefaultReceptor

func DefaultReceptor(
	ptr any,
	anyCallback func(StructField, string, func() reflect.Value) error,
	logger *slog.Logger,
) (*PairsReceptor, error)

DefaultReceptor sets default tag value to the struct field.

ptr should be a pointer of struct.

func EnvReceptor

func EnvReceptor(
	ptr any,
	anyCallback func(StructField, string, func() reflect.Value) error,
	logger *slog.Logger,
) (*PairsReceptor, error)

EnvReceptor sets environment variable value to the struct field.

ptr should be a pointer of struct.

func FlagSetReceptor

func FlagSetReceptor(typedReceptor TypedReceptor) *PairsReceptor

func PFlagGetReceptor

func PFlagGetReceptor(
	ptr any,
	fs *pflag.FlagSet,
	anyCallback func(StructField, string, func() reflect.Value) error,
	logger *slog.Logger,
) (*PairsReceptor, error)

PFlagGetReceptor returns a Receptor that can retrieve values from the parsed command-line flags.

func PFlagSetReceptor

func PFlagSetReceptor(fs *pflag.FlagSet) *PairsReceptor

PFlagSetReceptor returns a Receptor that can define the command-line flags.

func PairsSynthReceptor

func PairsSynthReceptor(
	get func(StructField) (string, error),
	converter Converter,
	typedReceptor TypedReceptor,
) *PairsReceptor

PairsSynthReceptor synthesizes Converter and TypedReceptor. get extracts the value from StructField, converter converts it and typedReceptor accepts it.

func SetReceptor

func SetReceptor(
	ptr any,
	get func(StructField) (string, error),
	converter Converter,
	anyCallback func(StructField, string, func() reflect.Value) error,
	onSet func(StructField, any),
) (*PairsReceptor, error)

SetReceptor returns a new PairsReceptor to set value to ptr.

ptr should be a pointer of struct. get should return a value to be set; false means not found. converter should convert result of get().

You can customize how unsupported field values are set by anyCallback, if nil, disable this feature. Example of anyCallback:

func(field StructField, str string, fieldPtr func() reflect.Value) error {
  var xs []int
  if err := json.Unmarshal([]byte(str), &xs); err != nil {
    return err
  }
  fieldPtr().Set(reflect.ValueOf(xs))
  return nil
}

anyCallback should parse str and set the value to fieldPtr.

func (PairsReceptor) Any

func (r PairsReceptor) Any(f StructField) error

func (PairsReceptor) Bool

func (r PairsReceptor) Bool(f StructField) error

func (PairsReceptor) BoolSlice added in v0.10.0

func (r PairsReceptor) BoolSlice(f StructField) error

func (PairsReceptor) Count added in v0.10.0

func (r PairsReceptor) Count(f StructField) error

func (PairsReceptor) Duration added in v0.10.0

func (r PairsReceptor) Duration(f StructField) error

func (PairsReceptor) Float32

func (r PairsReceptor) Float32(f StructField) error

func (PairsReceptor) Float32Slice added in v0.10.0

func (r PairsReceptor) Float32Slice(f StructField) error

func (PairsReceptor) Float64

func (r PairsReceptor) Float64(f StructField) error

func (PairsReceptor) Float64Slice added in v0.10.0

func (r PairsReceptor) Float64Slice(f StructField) error

func (PairsReceptor) Int

func (r PairsReceptor) Int(f StructField) error

func (PairsReceptor) Int8

func (r PairsReceptor) Int8(f StructField) error

func (PairsReceptor) Int16

func (r PairsReceptor) Int16(f StructField) error

func (PairsReceptor) Int32

func (r PairsReceptor) Int32(f StructField) error

func (PairsReceptor) Int32Slice added in v0.10.0

func (r PairsReceptor) Int32Slice(f StructField) error

func (PairsReceptor) Int64

func (r PairsReceptor) Int64(f StructField) error

func (PairsReceptor) Int64Slice added in v0.10.0

func (r PairsReceptor) Int64Slice(f StructField) error

func (PairsReceptor) IntSlice added in v0.10.0

func (r PairsReceptor) IntSlice(f StructField) error

func (PairsReceptor) String

func (r PairsReceptor) String(f StructField) error

func (PairsReceptor) StringSlice added in v0.10.0

func (r PairsReceptor) StringSlice(f StructField) error

func (PairsReceptor) Time added in v0.10.0

func (r PairsReceptor) Time(f StructField) error

func (PairsReceptor) Uint

func (r PairsReceptor) Uint(f StructField) error

func (PairsReceptor) Uint8

func (r PairsReceptor) Uint8(f StructField) error

func (PairsReceptor) Uint16

func (r PairsReceptor) Uint16(f StructField) error

func (PairsReceptor) Uint32

func (r PairsReceptor) Uint32(f StructField) error

func (PairsReceptor) Uint64

func (r PairsReceptor) Uint64(f StructField) error

func (PairsReceptor) UintSlice added in v0.10.0

func (r PairsReceptor) UintSlice(f StructField) error

type ParsePair

type ParsePair[T any] struct {
	// contains filtered or unexported fields
}

ParsePair defines a conversion of StructField that can fail.

func NewPairSynth

func NewPairSynth[T any](
	get func(StructField) (string, error),
	conv func(string) (T, error),
	callback func(StructField, T) error,
) *ParsePair[T]

NewPairSynth constructs a pair of functions to process StructField.

  • get: extract string from StructField
  • conv: convert the value
  • callback: accept the converted value

get and conv can return ErrParseAsDefault or ErrSkipParse.

func NewParsePair

func NewParsePair[T any](
	conv func(StructField) (T, error),
	callback func(StructField, T) error,
) *ParsePair[T]

func (*ParsePair[T]) Try

func (p *ParsePair[T]) Try(s StructField) error

type SliceReceptor added in v0.10.0

type SliceReceptor interface {
	BoolSlice(StructField) error
	IntSlice(StructField) error
	Int32Slice(StructField) error
	Int64Slice(StructField) error
	UintSlice(StructField) error
	Float32Slice(StructField) error
	Float64Slice(StructField) error
	StringSlice(StructField) error
}

type StringReceptor

type StringReceptor interface {
	String(StructField) error
}

type StructField

type StructField interface {
	Name() string
	Kind() reflect.Kind
	Tag() *Tag
	RType() reflect.Type
}

func NewStructField

func NewStructField(
	name string,
	kind reflect.Kind,
	tag *Tag,
	rType reflect.Type,
) StructField

type Supported

type Supported interface {
	~bool | constraints.Signed | Unsigned | ~string
}

type Tag

type Tag struct {
	// contains filtered or unexported fields
}

Tag is a tag of struct.

func NewTag

func NewTag(t reflect.StructTag, prefix string) *Tag

NewTag returns a new Tag. Tag retrieves values of all TagName, TagUsage, TagDefault. prefix adds a prefix to the tag names.

func (Tag) Count added in v0.10.0

func (t Tag) Count() bool

func (Tag) Default

func (t Tag) Default() (string, bool)

func (Tag) Name

func (t Tag) Name() (string, bool)

func (Tag) Sep added in v0.11.0

func (t Tag) Sep() string

func (Tag) Short added in v0.2.0

func (t Tag) Short() (string, bool)

func (Tag) Split added in v0.11.0

func (t Tag) Split() bool

func (Tag) String

func (t Tag) String() string

func (Tag) Usage

func (t Tag) Usage() string

type TimeReceptor added in v0.10.0

type TimeReceptor interface {
	Time(StructField) error
}

type Type

type Type struct {
	// contains filtered or unexported fields
}

Type is the metadata of struct.

func NewType

func NewType(v any, prefix string) (*Type, error)

NewType constructs Type from struct value. prefix is for Tag.

func (Type) Accept

func (t Type) Accept(r Receptor) error

Accept Call r on each of Type.Fields.

func (Type) Fields

func (t Type) Fields() []StructField

Fields returns the metadata of all fields of the struct.

func (Type) Name

func (t Type) Name() string

Name returns the name of the struct.

type TypedReceptor

type TypedReceptor interface {
	Bool(StructField, bool) error
	Int(StructField, int) error
	Int8(StructField, int8) error
	Int16(StructField, int16) error
	Int32(StructField, int32) error
	Int64(StructField, int64) error
	Uint(StructField, uint) error
	Uint8(StructField, uint8) error
	Uint16(StructField, uint16) error
	Uint32(StructField, uint32) error
	Uint64(StructField, uint64) error
	Float32(StructField, float32) error
	Float64(StructField, float64) error
	String(StructField, string) error
	BoolSlice(StructField, []bool) error
	IntSlice(StructField, []int) error
	Int32Slice(StructField, []int32) error
	Int64Slice(StructField, []int64) error
	UintSlice(StructField, []uint) error
	Float32Slice(StructField, []float32) error
	Float64Slice(StructField, []float64) error
	StringSlice(StructField, []string) error
	Duration(StructField, time.Duration) error
	Time(StructField, time.Time) error
	Count(StructField, int) error
	Any(StructField, string) error
}

TypedReceptor accepts a pair of StructField and some value.

type TypedReceptorFunc

type TypedReceptorFunc[T any] func(StructField, T) error

TypedReceptorFunc accepts a pair of StructField and some value.

func (TypedReceptorFunc[T]) Call

func (f TypedReceptorFunc[T]) Call(s StructField, v T) error

Call calls self if not nil.

type UintReceptor

type UintReceptor interface {
	Uint(StructField) error
	Uint8(StructField) error
	Uint16(StructField) error
	Uint32(StructField) error
	Uint64(StructField) error
}

type Unsigned

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

Jump to

Keyboard shortcuts

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