Documentation ¶
Index ¶
- func Each[T any](slice []T, f func(i int))
- func EscapeNilSlice(v interface{}) error
- func Ints[T any](slice []T, f func(i int) int) []int
- func IntsMap[T any](slice []T, mapper func(i int) (key, value int)) map[int][]int
- func IsNil(v interface{}) bool
- func RandDuration(from, to time.Duration) time.Duration
- func RandString(length int) string
- type CodeError
- type ErrorWithCode
- type ErrorWithHTTPCode
- type ErrorWithOrigin
- type Integer
- type JSONDate
- type JSONTime
- type JSONTimestamp
- type SQLJSON
- type Secret
- type StrInts
- type StrJSON
- type StrValue
- func (v StrValue) Bool() (bool, error)
- func (v StrValue) Default(value string) StrValue
- func (v StrValue) Float32() (float32, error)
- func (v StrValue) Float64() (float64, error)
- func (v StrValue) Int() (int, error)
- func (v StrValue) Int16() (int16, error)
- func (v StrValue) Int32() (int32, error)
- func (v StrValue) Int64() (int64, error)
- func (v StrValue) Int8() (int8, error)
- func (v StrValue) IsEmpty() bool
- func (v StrValue) String() string
- func (v StrValue) StringArray() []string
- func (v StrValue) Uint() (uint, error)
- func (v StrValue) Uint16() (uint16, error)
- func (v StrValue) Uint32() (uint32, error)
- func (v StrValue) Uint64() (uint64, error)
- func (v StrValue) Uint8() (uint8, error)
- type URI
- type URL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapeNilSlice ¶
func EscapeNilSlice(v interface{}) error
EscapeNilSlice 将数据中所有的 nil 切片或数组,设置为长度为 0 的空数组,避免前端处理失败。 注意:必须使用指针传递,否则无法替换掉nil
func RandDuration ¶
RandDuration 生成 [from, to) 区间内的随机时间间隔
Types ¶
type CodeError ¶
type CodeError struct {
// contains filtered or unexported fields
}
CodeError 带错误码的错误 支持自定义错误码,HTTP状态码,及原始错误 注意:不要直接对 CodeError 进行比较操作,可能因为设置了不同的 origin 而不相等
func NewCodeError ¶
NewCodeError 创建带错误码的错误
func (CodeError) WithOrigin ¶
type ErrorWithCode ¶
ErrorWithCode 支持自定义错误码的 error
type ErrorWithHTTPCode ¶
ErrorWithHTTPCode 支持自定义HTTP状态码的 error
type ErrorWithOrigin ¶
ErrorWithOrigin 支持返回原始错误的 error
type JSONDate ¶
JSONDate "YYYY-MM-DD"格式时间
func (JSONDate) MarshalJSON ¶
func (*JSONDate) UnmarshalJSON ¶
type JSONTime ¶
JSONTime "YYYY-MM-DD HH:MM:SS"格式时间
func (JSONTime) MarshalJSON ¶
func (*JSONTime) UnmarshalJSON ¶
type JSONTimestamp ¶
JSONTimestamp 时间戳格式时间
func (JSONTimestamp) MarshalJSON ¶
func (t JSONTimestamp) MarshalJSON() ([]byte, error)
func (JSONTimestamp) String ¶
func (d JSONTimestamp) String() string
func (*JSONTimestamp) UnmarshalJSON ¶
func (t *JSONTimestamp) UnmarshalJSON(bytes []byte) error
type StrJSON ¶
type StrJSON string
StrJSON 将字符串进行JSON序列化或反序列化 空字符串为`null`值,反之亦然
func (StrJSON) MarshalJSON ¶
func (*StrJSON) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.