Documentation ¶
Index ¶
- Variables
- func Contains[T comparable](list []T, v T) bool
- func ContainsOf[T any](list []T, f func(T) bool) bool
- func ExtractPointerOr[T any](value any, fallback ...T) T
- func Filter[T any](list []T, f func(T) bool) []T
- func GeneratePassword(password, salt string) (string, error)
- func GenerateSalt() string
- func Index[T comparable](list []T, v T) int
- func IndexOf[T any](list []T, f func(T) bool) int
- func IsNil(i interface{}) bool
- func MD5(str string) string
- func MapsMerge[K comparable, V any](ms ...map[K]V) map[K]V
- func Marshal(v any) ([]byte, error)
- func MergeSlice[T any](slices ...[]T) []T
- func MergeSliceWithUnique[T comparable](slices ...[]T) []T
- func Of[T any](v T) *T
- func RegisterCodec(codec encoding.Codec)
- func SetDefaultMarshalFn(fn func(v any) ([]byte, error))
- func SetDefaultUnmarshalFn(fn func(data []byte, v any) error)
- func SliceTo[T, R any](s []T, call func(T) R) []R
- func SliceToWithFilter[T, R any](s []T, call func(T) (R, bool)) []R
- func SliceUnique[T comparable](s []T) []T
- func SlicesHasDuplicates[T any, R comparable](arr []T, keyFunc func(T) R) bool
- func SlicesIntersection[T compare](slice1, slice2 []T) []T
- func Ternary[T any](condition bool, trueVal, falseVal T) T
- func TextIsNull(text string) bool
- func TextTrim(text string) string
- func TextTrimIsNull(text string) bool
- func To[T, R any](list []T, f func(T) R) []R
- func ToFilter[T, R any](list []T, f func(T) (R, bool)) []R
- func ToMap[T any, R comparable](list []T, f func(T) R) map[R]T
- func Unmarshal(data []byte, v any) error
- func UnwrapOr[T any](p *T, fallback ...T) T
- func ValidatePassword(password, checkPass, salt string) (err error)
- func WithPageQuery[T any](q PageQuery[T], page Pagination) error
- type Decoder
- type DecoderOption
- type Duration
- type IPaginationReq
- type PageQuery
- type Pagination
- type Password
- type Slice
- type Time
Constants ¶
This section is empty.
Variables ¶
var ErrValidatePassword = status.Error(http.StatusUnauthorized, "密码错误")
ErrValidatePassword 密码错误
Functions ¶
func ContainsOf ¶ added in v1.0.0
ContainsOf 是否包含
func ExtractPointerOr ¶ added in v1.0.0
ExtractPointerOr 解包多层指针, 如果为nil则返回指定的默认值(没有指定,则返回go默认值), 否则返回值本身
func GeneratePassword ¶ added in v1.0.0
GeneratePassword 生成密码
func MapsMerge ¶ added in v1.0.0
func MapsMerge[K comparable, V any](ms ...map[K]V) map[K]V
MapsMerge 合并多个map
func MergeSliceWithUnique ¶ added in v1.0.0
func MergeSliceWithUnique[T comparable](slices ...[]T) []T
MergeSliceWithUnique 合并切片,并去重
func RegisterCodec ¶ added in v1.0.2
RegisterCodec registers a codec with the default marshal and unmarshal functions.
func SetDefaultMarshalFn ¶ added in v1.0.2
SetDefaultMarshalFn sets the default marshal function.
func SetDefaultUnmarshalFn ¶ added in v1.0.2
SetDefaultUnmarshalFn sets the default unmarshal function.
func SliceTo ¶ added in v1.0.0
func SliceTo[T, R any](s []T, call func(T) R) []R
SliceTo 将slice转换为指定类型
func SliceToWithFilter ¶ added in v1.0.0
SliceToWithFilter 将slice转换为指定类型,并过滤掉指定的值
func SlicesHasDuplicates ¶ added in v1.0.0
func SlicesHasDuplicates[T any, R comparable](arr []T, keyFunc func(T) R) bool
SlicesHasDuplicates 是否有重复元素
func SlicesIntersection ¶ added in v1.0.0
func SlicesIntersection[T compare](slice1, slice2 []T) []T
SlicesIntersection 求交集
func TextTrimIsNull ¶ added in v1.0.2
TextTrimIsNull 判断字符串首尾空格后是否为空
func ToMap ¶ added in v1.0.0
func ToMap[T any, R comparable](list []T, f func(T) R) map[R]T
ToMap 切片转map
func UnwrapOr ¶ added in v1.0.0
func UnwrapOr[T any](p *T, fallback ...T) T
UnwrapOr 解包指针, 如果为nil则返回指定的默认值(没有指定,则返回go默认值), 否则返回值本身
func ValidatePassword ¶ added in v1.0.0
ValidatePassword 校验密码
func WithPageQuery ¶ added in v1.0.0
func WithPageQuery[T any](q PageQuery[T], page Pagination) error
WithPageQuery 分页查询
Types ¶
type Decoder ¶ added in v1.0.2
type Decoder struct {
// contains filtered or unexported fields
}
Decoder is a generic decoder that can be used to decode values.
func NewDecoder ¶ added in v1.0.2
func NewDecoder(r io.Reader, opts ...DecoderOption) *Decoder
NewDecoder creates a new decoder with the given options.
type DecoderOption ¶ added in v1.0.2
type DecoderOption func(*Decoder)
DecoderOption is a function that can be used to configure a decoder.
type Duration ¶ added in v1.0.0
type Duration struct {
Duration *durationpb.Duration
}
Duration 包装后的时间类型
func NewDuration ¶ added in v1.0.0
func NewDuration(dur *durationpb.Duration) *Duration
NewDuration 创建一个 Duration
func (*Duration) GetDuration ¶ added in v1.0.0
func (d *Duration) GetDuration() *durationpb.Duration
GetDuration 获取 Duration
type IPaginationReq ¶ added in v1.0.2
type PageQuery ¶ added in v1.0.0
type PageQuery[T any] interface { Limit(limit int) T Offset(offset int) T Count() (count int64, err error) }
PageQuery 分页查询
type Pagination ¶ added in v1.0.0
type Pagination interface { IPaginationReq GetTotal() int64 SetTotal(total int64) }
Pagination 分页器
func NewPagination ¶ added in v1.0.0
func NewPagination(page IPaginationReq) Pagination
NewPagination 获取分页器
type Password ¶ added in v1.0.0
type Password interface { GetEncryptValue() (string, error) GetValue() string GetSalt() string fmt.Stringer }
Password 密码
type Slice ¶ added in v1.0.2
type Slice[T comparable] []T
func NewUint32SlicePointer ¶ added in v1.0.2
NewUint32SlicePointer 创建 *Slice[uint32]
type Time ¶ added in v1.0.0
Time 包装后的时间类型
func NewTimeByString ¶ added in v1.0.0
NewTimeByString 从字符串创建一个 Time
func NewTimeByUnix ¶ added in v1.0.0
NewTimeByUnix 从unix 创建一个 Time