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 GetAPI(path string) string
- func GetRandomElement[T any](slice []T) T
- 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 JSONToMap(jsonStr string) (map[string]interface{}, error)
- func Limit(t any, limit int) any
- 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 TextJoin(s ...string) string
- func TextJoinByBytes(s ...[]byte) string
- func TextJoinByBytesToBytes(ss ...[]byte) []byte
- func TextJoinByStringer(s ...fmt.Stringer) string
- func TextJoinByStringerToBytes(ss ...fmt.Stringer) []byte
- func TextJoinToBytes(ss ...string) []byte
- 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 ToMapSlice[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 WithPageQuery[T any, Q PageQuery[T]](q Q, page Pagination) (T, error)
- type Decoder
- type DecoderOption
- type Duration
- func (d *Duration) CronTime() string
- func (d *Duration) GetDuration() *durationpb.Duration
- func (d *Duration) MarshalJSON() ([]byte, error)
- func (d *Duration) Scan(src any) error
- func (d *Duration) String() string
- func (d *Duration) UnmarshalJSON(data []byte) error
- func (d *Duration) Value() (driver.Value, error)
- type Encoder
- type IPaginationReq
- type Limiter
- 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 GetRandomElement ¶ added in v1.1.31
func GetRandomElement[T any](slice []T) T
GetRandomElement 获取随机元素
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 SetDefaultMarshalFn ¶ added in v1.0.2
SetDefaultMarshalFn 设置默认编码函数
func SetDefaultUnmarshalFn ¶ added in v1.0.2
SetDefaultUnmarshalFn 设置默认解码函数
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 TextJoinByBytes ¶ added in v1.1.0
TextJoinByBytes 拼接字符串
func TextJoinByBytesToBytes ¶ added in v1.1.0
TextJoinByBytesToBytes 拼接字符串
func TextJoinByStringer ¶ added in v1.1.0
TextJoinByStringer 拼接字符串
func TextJoinByStringerToBytes ¶ added in v1.1.0
TextJoinByStringerToBytes 拼接字符串
func TextJoinToBytes ¶ added in v1.1.0
TextJoinToBytes 拼接字符串
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 ToMapSlice ¶ added in v1.1.38
func ToMapSlice[T any, R comparable](list []T, f func(T) R) map[R][]T
ToMapSlice 切片转map value为切片
func UnwrapOr ¶ added in v1.0.0
func UnwrapOr[T any](p *T, fallback ...T) T
UnwrapOr 解包指针, 如果为nil则返回指定的默认值(没有指定,则返回go默认值), 否则返回值本身
func WithPageQuery ¶ added in v1.0.0
func WithPageQuery[T any, Q PageQuery[T]](q Q, page Pagination) (T, error)
WithPageQuery 分页查询
Types ¶
type Decoder ¶ added in v1.0.2
type Decoder struct {
// contains filtered or unexported fields
}
Decoder 解码器
func NewDecoder ¶ added in v1.0.2
func NewDecoder(r io.Reader, opts ...DecoderOption) *Decoder
NewDecoder 创建一个解码器
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
func (*Duration) MarshalJSON ¶ added in v1.1.0
MarshalJSON 实现 json.Marshaler 接口
func (*Duration) UnmarshalJSON ¶ added in v1.1.0
UnmarshalJSON 实现 json.Unmarshaler 接口
type Encoder ¶ added in v1.1.37
type Encoder struct {
// contains filtered or unexported fields
}
Encoder 编码器
type IPaginationReq ¶ added in v1.0.2
IPaginationReq 分页请求参数接口
type PageQuery ¶ added in v1.0.0
type PageQuery[T any] interface { Limit(limit int) T Offset(offset int) T Where(conds ...gen.Condition) 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 { GetValue() string GetSalt() string fmt.Stringer Validate(checkPass string) error }
Password 密码
type Slice ¶ added in v1.0.2
type Slice[T comparable] []T
Slice 切片
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
func (*Time) MarshalJSON ¶ added in v1.1.0
MarshalJSON 实现 json.Marshaler 接口
func (*Time) UnmarshalJSON ¶ added in v1.1.0
UnmarshalJSON 实现 json.Unmarshaler 接口