Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = NewHttpError(http.StatusNotFound) ErrBadRequest = NewHttpError(http.StatusBadRequest) ErrInternalServerError = NewHttpError(http.StatusInternalServerError) )
Functions ¶
Types ¶
type Error ¶
type Error struct {
Code int `json:"code"`
Key string `json:"error,omitempty"`
Success bool `json:"success"`
Message string `json:"message"`
Internal error `json:"-"`
}
Error 异常结构
func NewHttpError ¶
type KV ¶ added in v0.3.10
type KV[K comparable, V any] struct { Key string `json:"key"` Value string `json:"value"` }
type Optional ¶ added in v0.3.4
type Optional[T any] struct { // contains filtered or unexported fields }
Optional 定义一个 Optional 类型。
func NewOptional ¶ added in v0.3.4
NewOptional 创建一个新的 Optional 对象。
func (Optional[T]) IfPresent ¶ added in v0.3.4
func (o Optional[T]) IfPresent(consumer func(T))
IfPresent 如果 Optional 对象不为空,则执行给定的消费者。
type Pager ¶ added in v0.3.10
type Pager[T any] struct { PageNumber int64 `json:"pageNumber"` PageSize int64 `json:"pageSize"` TotalPage int64 `json:"totalPage"` TotalRow int64 `json:"totalRow"` Count bool `json:"count"` HasNext bool `json:"hasNext"` Data []T `json:"data"` }
func PageConvert ¶ added in v0.3.10
PageConvert takes a transformation function and applies it to each element in the Data slice. The function is also generic, accepting a slice of any type T and returning a slice of any type
type Pair ¶ added in v0.3.10
type Pair[K comparable, V any] struct { KV[K, V] }
type Result ¶
type Result struct {
Code int `json:"code"`
Success bool `json:"success,omitempty"`
Message interface{} `json:"message,omitempty"`
Data interface{} `json:"data,omitempty"`
}
Result 返回结果
type Tuple3 ¶ added in v0.3.10
type Tuple3[T1, T2, T3 any] struct { T1 T1 `json:"t1"` T2 T2 `json:"t2"` T3 T3 `json:"t3"` }
Click to show internal directories.
Click to hide internal directories.