Documentation ¶
Index ¶
- func AssertPanic(t *testing.T, f func(), msg interface{})
- func CanConvert[FromType any, ToType any]() bool
- func Float32() float32
- func Float64() float64
- func Get(url string, headers map[string]string, result any) error
- func HasField(t reflect.Type, name string) bool
- func Int63() int64
- func Intn(n int) int
- func IsSortDesc(sort string) bool
- func Letters(n int) string
- func Post(url, contentType string, body any, result any) error
- func PostUrlForm(path string, body map[string]string, result any) error
- func Ptr[T any](v T) *T
- func Ptrs[T any](v []T) []*T
- func ToJsonMapString(v any) map[string]string
- func ToUint(s string) uint64
- func TypeOf[T any]() reflect.Type
- func Zero[T any]() T
- type BigInt
- type ID
- type IdGenerator
- type IdGeneratorOptions
- type Int64IdGenerator
- type NullableTime
- func (t *NullableTime) Format(layout string) string
- func (t *NullableTime) IsNil() bool
- func (t *NullableTime) IsZero() bool
- func (t NullableTime) MarshalJSON() ([]byte, error)
- func (t *NullableTime) SetNil()
- func (t *NullableTime) SetTime(time time.Time)
- func (t *NullableTime) String() string
- func (t *NullableTime) Time() *time.Time
- func (t *NullableTime) UnmarshalJSON(data []byte) error
- type PageAndSort
- type PageParam
- type PagedResult
- type Set
- type StringID
- type StringIdGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertPanic ¶
func CanConvert ¶
CanConvert returns true if FromType can be converted to ToType.
func IsSortDesc ¶
func ToJsonMapString ¶
Types ¶
type BigInt ¶
type BigInt struct {
// contains filtered or unexported fields
}
func ParseBigInt ¶
func (*BigInt) MarshalBSON ¶
func (*BigInt) MarshalJSON ¶
func (*BigInt) UnmarshalBSON ¶
func (*BigInt) UnmarshalJSON ¶
type IdGenerator ¶
type IdGenerator[T comparable] interface { Create() T }
func NewNumberIdGenerator ¶
func NewNumberIdGenerator[T ~int64]() *IdGenerator[T]
func NewStringIdGenerator ¶
func NewStringIdGenerator[T ~string]() *IdGenerator[T]
type IdGeneratorOptions ¶
type Int64IdGenerator ¶
type Int64IdGenerator[T ~int64] struct { }
func (*Int64IdGenerator[T]) Create ¶
func (u *Int64IdGenerator[T]) Create() T
type NullableTime ¶
type NullableTime struct {
// contains filtered or unexported fields
}
NullableTime is a wrapper of time.Time, which can be marshaled to JSON as RFC3339 format. It can be used as a nullable time.Time field. empty value is zero time value is null or time
func (*NullableTime) Format ¶
func (t *NullableTime) Format(layout string) string
func (*NullableTime) IsNil ¶
func (t *NullableTime) IsNil() bool
func (*NullableTime) IsZero ¶
func (t *NullableTime) IsZero() bool
func (NullableTime) MarshalJSON ¶
func (t NullableTime) MarshalJSON() ([]byte, error)
func (*NullableTime) SetNil ¶
func (t *NullableTime) SetNil()
func (*NullableTime) SetTime ¶
func (t *NullableTime) SetTime(time time.Time)
func (*NullableTime) String ¶
func (t *NullableTime) String() string
func (*NullableTime) Time ¶
func (t *NullableTime) Time() *time.Time
func (*NullableTime) UnmarshalJSON ¶
func (t *NullableTime) UnmarshalJSON(data []byte) error
type PageAndSort ¶
type PageAndSort struct { PageParam `json:",inline"` // 页码, 从1开始 Sort string `json:"sort"` // 排序字段, 例如: -createdAt, +updatedAt }
func NewPageAndSort ¶
func NewPageAndSort(page, pageSize int64, sort string) *PageAndSort
NewPageAndSort new page and sort
func NewPageAndSortWithId ¶
func NewPageAndSortWithId(includedId any, pageSize int64, sort string) *PageAndSort
func PageLimit ¶
func PageLimit(limit int) *PageAndSort
func (*PageAndSort) Copy ¶
func (p *PageAndSort) Copy() *PageAndSort
type PageParam ¶
type PageParam struct { Page int64 `json:"page"` // 页码, 从1开始 PageSize int64 `json:"pageSize"` // 每页大小 IncludeTotal bool `json:"includeTotal"` // 是否包含总数 IncludedId any `json:"id"` // 包含指定Id的数据,用于分页查询,这时候不需要传入page }
func PageParamWithId ¶
type PagedResult ¶
type Set ¶
type Set[T comparable] map[T]struct{}
Set is a set of items. It is implemented as a map[T]struct{}.
func NewSet ¶
func NewSet[T comparable](items ...T) Set[T]
type StringIdGenerator ¶
type StringIdGenerator[T ~string] struct { }
func (*StringIdGenerator[T]) Create ¶
func (u *StringIdGenerator[T]) Create() T
Click to show internal directories.
Click to hide internal directories.