Documentation
¶
Overview ¶
From html/template/content.go Copyright 2011 The Go Authors. All rights reserved.
Index ¶
- func IsCastError(err error) bool
- func IsNilError(err error) bool
- func IsOverflowError(err error) bool
- func ToBool(value interface{}) (bool, error)
- func ToBoolSlice(i interface{}) ([]bool, error)
- func ToFloat[T float32 | float64](value interface{}) (T, error)
- func ToFloatSlice[T float32 | float64](i interface{}) ([]T, error)
- func ToSigned[T int | int8 | int16 | int32 | int64](value interface{}) (T, error)
- func ToSignedSlice[T int | int8 | int16 | int32 | int64](i interface{}) ([]T, error)
- func ToSlice(value interface{}) ([]interface{}, error)
- func ToString(value interface{}) (string, error)
- func ToStringSlice(i interface{}) ([]string, error)
- func ToUnsigned[T uint | uint8 | uint16 | uint32 | uint64](value interface{}) (T, error)
- func ToUnsignedSlice[T uint | uint8 | uint16 | uint32 | uint64](i interface{}) ([]T, error)
- type BoolErrorProvider
- type BoolProvider
- type BoolSliceErrorProvider
- type BoolSliceProvider
- type Caster
- type Float32ErrorProvider
- type Float32Provider
- type Float32SliceErrorProvider
- type Float32SliceProvider
- type Float64ErrorProvider
- type Float64Provider
- type Float64SliceErrorProvider
- type Float64SliceProvider
- type Int8ErrorProvider
- type Int8Provider
- type Int8SliceErrorProvider
- type Int8SliceProvider
- type Int16ErrorProvider
- type Int16Provider
- type Int16SliceErrorProvider
- type Int16SliceProvider
- type Int32ErrorProvider
- type Int32Provider
- type Int32SliceErrorProvider
- type Int32SliceProvider
- type Int64ErrorProvider
- type Int64Provider
- type Int64SliceErrorProvider
- type Int64SliceProvider
- type IntErrorProvider
- type IntProvider
- type IntSliceErrorProvider
- type IntSliceProvider
- type SliceErrorProvider
- type SliceProvider
- type StringErrorProvider
- type StringProvider
- type StringSliceErrorProvider
- type StringSliceProvider
- type Uint8ErrorProvider
- type Uint8Provider
- type Uint8SliceErrorProvider
- type Uint8SliceProvider
- type Uint16ErrorProvider
- type Uint16Provider
- type Uint16SliceErrorProvider
- type Uint16SliceProvider
- type Uint32ErrorProvider
- type Uint32Provider
- type Uint32SliceErrorProvider
- type Uint32SliceProvider
- type Uint64ErrorProvider
- type Uint64Provider
- type Uint64SliceErrorProvider
- type Uint64SliceProvider
- type UintErrorProvider
- type UintProvider
- type UintSliceErrorProvider
- type UintSliceProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCastError ¶
IsCastError checks if the provided error is a casting error. It returns true if the error is not nil and its a casting error.
func IsNilError ¶
IsNilError checks if the provided error is a bil error. It returns true if the error is not nil and its nil error.
func IsOverflowError ¶
IsOverflowError checks if the provided error is a overflow error. It returns true if the error is not nil and its a overflow error.
func ToBoolSlice ¶
ToBoolSlice casts an interface to a []bool type.
func ToFloatSlice ¶
ToFloatSlice casts an interface to a float slice type.
func ToSignedSlice ¶
ToSignedSlice casts an interface to a signed integer slice type.
func ToSlice ¶
func ToSlice(value interface{}) ([]interface{}, error)
ToSlice casts an interface{} to a []interface{} type.
func ToStringSlice ¶
ToStringSlice casts an interface to a []string type.
func ToUnsigned ¶
ToUnsigned casts an interface to a unsigned integer type.
Types ¶
type BoolErrorProvider ¶
BoolErrorProvider is an interface that provides a method to return a boolean value with an error.
type BoolProvider ¶
type BoolProvider interface {
Bool() bool
}
BoolProvider is an interface that provides a method to return a boolean value.
type BoolSliceErrorProvider ¶
BoolSliceErrorProvider is an interface that provides a method to return a slice of boolean values with an error.
type BoolSliceProvider ¶
type BoolSliceProvider interface {
BoolSlice() []bool
}
BoolSliceProvider is an interface that provides a method to return a slice of boolean values.
type Caster ¶
type Caster interface {
// IsNil checks if the value is nil.
IsNil() bool
// Interface returns the value as an interface{}.
Interface() any
// Unmarshal unmarshal value using json decoder.
Unmarshal(out any) error
// Bool converts the value to a bool.
Bool() (bool, error)
// BoolSafe converts the value to a bool, returning a fallback value in case of an error.
BoolSafe(fallback bool) bool
// Int converts the value to an int.
Int() (int, error)
// IntSafe converts the value to an int, returning a fallback value in case of an error.
IntSafe(fallback int) int
// Int8 converts the value to an int8.
Int8() (int8, error)
// Int8Safe converts the value to an int8, returning a fallback value in case of an error.
Int8Safe(fallback int8) int8
// Int16 converts the value to an int16.
Int16() (int16, error)
// Int16Safe converts the value to an int16, returning a fallback value in case of an error.
Int16Safe(fallback int16) int16
// Int32 converts the value to an int32.
Int32() (int32, error)
// Int32Safe converts the value to an int32, returning a fallback value in case of an error.
Int32Safe(fallback int32) int32
// Int64 converts the value to an int64.
Int64() (int64, error)
// Int64Safe converts the value to an int64, returning a fallback value in case of an error.
Int64Safe(fallback int64) int64
// Uint converts the value to a uint.
Uint() (uint, error)
// UintSafe converts the value to a uint, returning a fallback value in case of an error.
UintSafe(fallback uint) uint
// Uint8 converts the value to a uint8.
Uint8() (uint8, error)
// Uint8Safe converts the value to a uint8, returning a fallback value in case of an error.
Uint8Safe(fallback uint8) uint8
// Uint16 converts the value to a uint16.
Uint16() (uint16, error)
// Uint16Safe converts the value to a uint16, returning a fallback value in case of an error.
Uint16Safe(fallback uint16) uint16
// Uint32 converts the value to a uint32.
Uint32() (uint32, error)
// Uint32Safe converts the value to a uint32, returning a fallback value in case of an error.
Uint32Safe(fallback uint32) uint32
// Uint64 converts the value to a uint64.
Uint64() (uint64, error)
// Uint64Safe converts the value to a uint64, returning a fallback value in case of an error.
Uint64Safe(fallback uint64) uint64
// Float32 converts the value to a float32.
Float32() (float32, error)
// Float32Safe converts the value to a float32, returning a fallback value in case of an error.
Float32Safe(fallback float32) float32
// Float64 converts the value to a float64.
Float64() (float64, error)
// Float64Safe converts the value to a float64, returning a fallback value in case of an error.
Float64Safe(fallback float64) float64
// String converts the value to a string.
String() (string, error)
// StringSafe converts the value to a string, returning a fallback value in case of an error.
StringSafe(fallback string) string
// Slice returns the value as a slice of interface{}.
Slice() ([]any, error)
// Slice returns the value as a slice of interface{}.
SliceSafe(fallback []any) []any
// BoolSlice converts the value to a slice of bool.
BoolSlice() ([]bool, error)
// BoolSliceSafe converts the value to a slice of bool, returning a fallback value in case of an error.
BoolSliceSafe(fallback []bool) []bool
// IntSlice converts the value to a slice of int.
IntSlice() ([]int, error)
// IntSliceSafe converts the value to a slice of int, returning a fallback value in case of an error.
IntSliceSafe(fallback []int) []int
// Int8Slice converts the value to a slice of int8.
Int8Slice() ([]int8, error)
// Int8SliceSafe converts the value to a slice of int8, returning a fallback value in case of an error.
Int8SliceSafe(fallback []int8) []int8
// Int16Slice converts the value to a slice of int16.
Int16Slice() ([]int16, error)
// Int16SliceSafe converts the value to a slice of int16, returning a fallback value in case of an error.
Int16SliceSafe(fallback []int16) []int16
// Int32Slice converts the value to a slice of int32.
Int32Slice() ([]int32, error)
// Int32SliceSafe converts the value to a slice of int32, returning a fallback value in case of an error.
Int32SliceSafe(fallback []int32) []int32
// Int64Slice converts the value to a slice of int64.
Int64Slice() ([]int64, error)
// Int64SliceSafe converts the value to a slice of int64, returning a fallback value in case of an error.
Int64SliceSafe(fallback []int64) []int64
// UintSlice converts the value to a slice of uint.
UintSlice() ([]uint, error)
// UintSliceSafe converts the value to a slice of uint, returning a fallback value in case of an error.
UintSliceSafe(fallback []uint) []uint
// Uint8Slice converts the value to a slice of uint8.
Uint8Slice() ([]uint8, error)
// Uint8SliceSafe converts the value to a slice of uint8, returning a fallback value in case of an error.
Uint8SliceSafe(fallback []uint8) []uint8
// Uint16Slice converts the value to a slice of uint16.
Uint16Slice() ([]uint16, error)
// Uint16SliceSafe converts the value to a slice of uint16, returning a fallback value in case of an error.
Uint16SliceSafe(fallback []uint16) []uint16
// Uint32Slice converts the value to a slice of uint32.
Uint32Slice() ([]uint32, error)
// Uint32SliceSafe converts the value to a slice of uint32, returning a fallback value in case of an error.
Uint32SliceSafe(fallback []uint32) []uint32
// Uint64Slice converts the value to a slice of uint64.
Uint64Slice() ([]uint64, error)
// Uint64SliceSafe converts the value to a slice of uint64, returning a fallback value in case of an error.
Uint64SliceSafe(fallback []uint64) []uint64
// Float32Slice converts the value to a slice of float32.
Float32Slice() ([]float32, error)
// Float32SliceSafe converts the value to a slice of float32, returning a fallback value in case of an error.
Float32SliceSafe(fallback []float32) []float32
// Float64Slice converts the value to a slice of float64.
Float64Slice() ([]float64, error)
// Float64SliceSafe converts the value to a slice of float64, returning a fallback value in case of an error.
Float64SliceSafe(fallback []float64) []float64
// StringSlice converts the value to a slice of string.
StringSlice() ([]string, error)
// StringSliceSafe converts the value to a slice of string, returning a fallback value in case of an error.
StringSliceSafe(fallback []string) []string
}
Caster is an interface that provides methods for type casting and conversion. It includes methods for checking if a value is nil, retrieving the value as an interface, and converting the value to primary go types such as bool, int, uint, float, and string. Each type conversion method has a corresponding safe method that returns a fallback value in case of an error, and methods for converting to slices of each type.
func NewCaster ¶
func NewCaster(v interface{}) Caster
NewCaster creates a new instance of a Caster with the provided value. The value can be of any type and will be used for type casting and conversion through the methods defined in the Caster interface.
Parameters:
- v: The value to be used for type casting and conversion.
Returns:
- Caster: An instance of the Caster interface that provides methods for type casting and conversion.
type Float32ErrorProvider ¶
Float32ErrorProvider is an interface that provides a method to return a float32 value with an error.
type Float32Provider ¶
type Float32Provider interface {
Float32() float32
}
Float32Provider is an interface that provides a method to return a float32 value.
type Float32SliceErrorProvider ¶
Float32SliceErrorProvider is an interface that provides a method to return a slice of float32 values with an error.
type Float32SliceProvider ¶
type Float32SliceProvider interface {
Float32Slice() []float32
}
Float32SliceProvider is an interface that provides a method to return a slice of float32 values.
type Float64ErrorProvider ¶
Float64ErrorProvider is an interface that provides a method to return a float64 value with an error.
type Float64Provider ¶
type Float64Provider interface {
Float64() float64
}
Float64Provider is an interface that provides a method to return a float64 value.
type Float64SliceErrorProvider ¶
Float64SliceErrorProvider is an interface that provides a method to return a slice of float64 values with an error.
type Float64SliceProvider ¶
type Float64SliceProvider interface {
Float64Slice() []float64
}
Float64SliceProvider is an interface that provides a method to return a slice of float64 values.
type Int8ErrorProvider ¶
Int8ErrorProvider is an interface that provides a method to return an int8 value with an error.
type Int8Provider ¶
type Int8Provider interface {
Int8() int8
}
Int8Provider is an interface that provides a method to return an int8 value.
type Int8SliceErrorProvider ¶
Int8SliceErrorProvider is an interface that provides a method to return a slice of int8 values with an error.
type Int8SliceProvider ¶
type Int8SliceProvider interface {
Int8Slice() []int8
}
Int8SliceProvider is an interface that provides a method to return a slice of int8 values.
type Int16ErrorProvider ¶
Int16ErrorProvider is an interface that provides a method to return an int16 value with an error.
type Int16Provider ¶
type Int16Provider interface {
Int16() int16
}
Int16Provider is an interface that provides a method to return an int16 value.
type Int16SliceErrorProvider ¶
Int16SliceErrorProvider is an interface that provides a method to return a slice of int16 values with an error.
type Int16SliceProvider ¶
type Int16SliceProvider interface {
Int16Slice() []int16
}
Int16SliceProvider is an interface that provides a method to return a slice of int16 values.
type Int32ErrorProvider ¶
Int32ErrorProvider is an interface that provides a method to return an int32 value with an error.
type Int32Provider ¶
type Int32Provider interface {
Int32() int32
}
Int32Provider is an interface that provides a method to return an int32 value.
type Int32SliceErrorProvider ¶
Int32SliceErrorProvider is an interface that provides a method to return a slice of int32 values with an error.
type Int32SliceProvider ¶
type Int32SliceProvider interface {
Int32Slice() []int32
}
Int32SliceProvider is an interface that provides a method to return a slice of int32 values.
type Int64ErrorProvider ¶
Int64ErrorProvider is an interface that provides a method to return an int64 value with an error.
type Int64Provider ¶
type Int64Provider interface {
Int64() int64
}
Int64Provider is an interface that provides a method to return an int64 value.
type Int64SliceErrorProvider ¶
Int64SliceErrorProvider is an interface that provides a method to return a slice of int64 values with an error.
type Int64SliceProvider ¶
type Int64SliceProvider interface {
Int64Slice() []int64
}
Int64SliceProvider is an interface that provides a method to return a slice of int64 values.
type IntErrorProvider ¶
IntErrorProvider is an interface that provides a method to return an integer value with an error.
type IntProvider ¶
type IntProvider interface {
Int() int
}
IntProvider is an interface that provides a method to return an integer value.
type IntSliceErrorProvider ¶
IntSliceErrorProvider is an interface that provides a method to return a slice of integer values with an error.
type IntSliceProvider ¶
type IntSliceProvider interface {
IntSlice() []int
}
IntSliceProvider is an interface that provides a method to return a slice of integer values.
type SliceErrorProvider ¶
SliceErrorProvider is an interface that provides a method to return a slice of any type with an error.
type SliceProvider ¶
type SliceProvider interface {
Slice() []any
}
SliceProvider is an interface that provides a method to return a slice of any type.
type StringErrorProvider ¶
StringErrorProvider is an interface that provides a method to return a string value with an error.
type StringProvider ¶
type StringProvider interface {
String() string
}
StringProvider is an interface that provides a method to return a string value.
type StringSliceErrorProvider ¶
StringSliceErrorProvider is an interface that provides a method to return a slice of string values with an error.
type StringSliceProvider ¶
type StringSliceProvider interface {
StringSlice() []string
}
StringSliceProvider is an interface that provides a method to return a slice of string values.
type Uint8ErrorProvider ¶
Uint8ErrorProvider is an interface that provides a method to return a uint8 value with an error.
type Uint8Provider ¶
type Uint8Provider interface {
Uint8() uint8
}
Uint8Provider is an interface that provides a method to return a uint8 value.
type Uint8SliceErrorProvider ¶
Uint8SliceErrorProvider is an interface that provides a method to return a slice of uint8 values with an error.
type Uint8SliceProvider ¶
type Uint8SliceProvider interface {
Uint8Slice() []uint8
}
Uint8SliceProvider is an interface that provides a method to return a slice of uint8 values.
type Uint16ErrorProvider ¶
Uint16ErrorProvider is an interface that provides a method to return a uint16 value with an error.
type Uint16Provider ¶
type Uint16Provider interface {
Uint16() uint16
}
Uint16Provider is an interface that provides a method to return a uint16 value.
type Uint16SliceErrorProvider ¶
Uint16SliceErrorProvider is an interface that provides a method to return a slice of uint16 values with an error.
type Uint16SliceProvider ¶
type Uint16SliceProvider interface {
Uint16Slice() []uint16
}
Uint16SliceProvider is an interface that provides a method to return a slice of uint16 values.
type Uint32ErrorProvider ¶
Uint32ErrorProvider is an interface that provides a method to return a uint32 value with an error.
type Uint32Provider ¶
type Uint32Provider interface {
Uint32() uint32
}
Uint32Provider is an interface that provides a method to return a uint32 value.
type Uint32SliceErrorProvider ¶
Uint32SliceErrorProvider is an interface that provides a method to return a slice of uint32 values with an error.
type Uint32SliceProvider ¶
type Uint32SliceProvider interface {
Uint32Slice() []uint32
}
Uint32SliceProvider is an interface that provides a method to return a slice of uint32 values.
type Uint64ErrorProvider ¶
Uint64ErrorProvider is an interface that provides a method to return a uint64 value with an error.
type Uint64Provider ¶
type Uint64Provider interface {
Uint64() uint64
}
Uint64Provider is an interface that provides a method to return a uint64 value.
type Uint64SliceErrorProvider ¶
Uint64SliceErrorProvider is an interface that provides a method to return a slice of uint64 values with an error.
type Uint64SliceProvider ¶
type Uint64SliceProvider interface {
Uint64Slice() []uint64
}
Uint64SliceProvider is an interface that provides a method to return a slice of uint64 values.
type UintErrorProvider ¶
UintErrorProvider is an interface that provides a method to return a uint value with an error.
type UintProvider ¶
type UintProvider interface {
Uint() uint
}
UintProvider is an interface that provides a method to return a uint value.
type UintSliceErrorProvider ¶
UintSliceErrorProvider is an interface that provides a method to return a slice of uint values with an error.
type UintSliceProvider ¶
type UintSliceProvider interface {
UintSlice() []uint
}
UintSliceProvider is an interface that provides a method to return a slice of uint values.