Documentation ¶
Index ¶
- Variables
- func Call(f FuncOne) (err error)
- func Call2[T any](f func() (T, error)) (res T, err error)
- func Call3[T any, V any](f FuncThree[T, V]) (res T, res2 V, err error)
- func CallNoop(f FuncNoop) error
- func CallType[T any](f FuncType[T]) (T, error)
- func CheckPassword(origin, password string) (isValid bool, err error)
- func CheckUploadHash(uploadId, targetId int64, hash string) (bool, error)
- func CheckUploadToken(account string, ts int64, id int64, mod int8, path string, token string) (bool, error)
- func CreateCaptcha(num int) string
- func CreatePassword(password string) (string, error)
- func CreateUploadToken(account string, ts int64, id int64, mod int8, path string) (string, error)
- func EnsureCountNoError(count int64, err error)
- func EnsureFound(value any)
- func EnsureFoundNoError(found bool, err error)
- func EnsureIgnoreFirstNoError(count any, err error)
- func EnsureNoError(err error)
- func FiName(fi fs.FileInfo) string
- func FormatEmail(email string) string
- func FormatPhone(phone string) string
- func GenerateHMAC(text string, key string) (string, error)
- func GetEnv(name EnvKey) string
- func GetEnvBool(name EnvKey) bool
- func GetEnvBoolDefault(name EnvKey, defaultValue bool) bool
- func GetEnvDefault(name EnvKey, defaultValue string) string
- func GetEnvInt[T int | uint | int64 | uint64](name EnvKey) T
- func GetEnvIntDefault[T int | uint | int64 | uint64](name EnvKey, defaultValue T) T
- func HashUuid() string
- func InitSnowflake(node int64) error
- func IntToStrWithPad(num int, length int, pad string) string
- func MakeUploadHash(uploadId, targetId int64) (string, error)
- func RandomChar(n int) string
- func RandomCharset(n int, charset string) string
- func RandomNumber(n int) string
- func RandomString(n int) string
- func ResolveCmd(cmd string) string
- func ShortUuid() string
- func SliceExchange[T any, V any](s []T, exchanger SliceExchangRunner[T, V]) []V
- func SliceFilter[T any](s []T, filter SliceFilterRunner[T]) []T
- func SnowCode() string
- func SnowId() int64
- func SnowWithPrefix(prefix string, id *int64) string
- func SortSlice[T any](list []T, cmp SortCompare[T])
- func SortSliceStable[T any](list []T, cmp SortCompare[T])
- func Spawn(cmd string, args []string, opt *SpawnOptions) (spawnOutput, error)
- func SpawnSimple(cmd string, args []string) (spawnOutput, error)
- func SqlColAs(field string, field2 string) string
- func SqlDeleted() string
- func SqlNotDeleted() string
- func SqlWhereEq(field string) string
- func SqlWhereGt(field string) string
- func SqlWhereIsNull(field string) string
- func SqlWhereLike(field string) string
- func SqlWherePrefix(field string) string
- func StrPad(s string, length int, pad string) string
- func StrPadPrefix(s string, length int, pad string) string
- func TimeStamp() string
- func Uuid() string
- func ValueOf[T any](value *T) T
- func ValueTo[T any](value T) *T
- func VerifyHMAC(HMAC string, text string, key string) (bool, error)
- func WithRecover(fn func() error) (err error)
- func Wrap(f FuncOne) func() error
- func Wrap2[T any](f FuncTwo[T]) func() (T, error)
- func Wrap3[T any, V any](f FuncThree[T, V]) func() (T, V, error)
- type AnySlice
- type AnySort
- type Array
- func (arr *Array[T]) Concat(next Array[T])
- func (arr *Array[T]) Filter(f func(any any) bool) Array[T]
- func (arr *Array[T]) ForEach(f func(e any))
- func (arr *Array[T]) Insert(i int, e ...T)
- func (arr *Array[T]) Pop() any
- func (arr *Array[T]) Push(e ...T)
- func (arr *Array[T]) Remove(i int)
- func (arr *Array[T]) Shift() *T
- func (arr *Array[T]) Unshift(e ...T)
- type ClientErrorCode
- type Data
- type DeleteStatus
- type EnvGetter
- func (getter *EnvGetter) Bool() bool
- func (getter *EnvGetter) Int() (r int)
- func (getter *EnvGetter) Int64() (r int64)
- func (getter *EnvGetter) KeyName() string
- func (getter *EnvGetter) Kind() reflect.Kind
- func (getter *EnvGetter) String() string
- func (getter *EnvGetter) UInt() (r uint)
- func (getter *EnvGetter) UInt64() (r uint64)
- func (getter *EnvGetter) Value() any
- type EnvKey
- type Error
- func (e *Error) Clone() *Error
- func (e *Error) Error() string
- func (e *Error) GetError() error
- func (e *Error) GinError() (int, error)
- func (e *Error) JsonError() (int, interface{})
- func (e *Error) Panic()
- func (e *Error) PanicError(err error)
- func (e *Error) WithCode(code string) *Error
- func (e *Error) WithMessage(message string) *Error
- func (e *Error) WithStack(stack error) *Error
- type FuncNoop
- type FuncOne
- type FuncThree
- type FuncTwo
- type FuncType
- type PageInfo
- type Runner
- type ServerErrorCode
- type SimpleArray
- func (arr *SimpleArray[T]) Concat(next SimpleArray[T])
- func (arr SimpleArray[T]) Contains(e T) bool
- func (arr *SimpleArray[T]) Delete(e T) bool
- func (arr SimpleArray[T]) DeleteMany(e T) int
- func (arr SimpleArray[T]) Filter(f func(T) bool) SimpleArray[T]
- func (arr SimpleArray[T]) ForEach(f func(e T))
- func (arr SimpleArray[T]) IndexOf(e T) int
- func (arr *SimpleArray[T]) Insert(i int, e ...T)
- func (arr SimpleArray[T]) Join(sep string) string
- func (arr SimpleArray[T]) LastIndexOf(e T) int
- func (arr SimpleArray[T]) Map(f func(T) T) SimpleArray[T]
- func (arr *SimpleArray[T]) Push(e ...T)
- func (arr *SimpleArray[T]) Remove(i int)
- func (arr *SimpleArray[T]) Unshift(e ...T)
- type SimpleType
- type SliceExchangRunner
- type SliceFilterRunner
- type SortCompare
- type SortPeek
- type SpawnOptions
- type SqlFieldType
- func (s SqlFieldType) Eq(value any) (string, any)
- func (s SqlFieldType) Gt(value any) (string, any)
- func (s SqlFieldType) Gte(value any) (string, any)
- func (s SqlFieldType) IsNull() string
- func (s SqlFieldType) Like(value any) (string, any)
- func (s SqlFieldType) Lt(value any) (string, any)
- func (s SqlFieldType) Lte(value any) (string, any)
- func (s SqlFieldType) Neq(value any) (string, any)
- func (s SqlFieldType) NotIsNull() string
- func (s SqlFieldType) OrderAsc() string
- func (s SqlFieldType) OrderDesc() string
- func (s SqlFieldType) Prefix(value any) (string, any)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // 200 Success = NewError(http.StatusOK, http.StatusText(http.StatusOK)) // 500 InternalServerError = NewError(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) NotImplemented = NewError(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) // 400 BadRequest = NewError(http.StatusBadRequest, http.StatusText(http.StatusBadRequest)) // 客户端请求错误 NotFound = NewError(http.StatusNotFound, http.StatusText(http.StatusNotFound)) // 服务器不可访问 Forbidden = NewError(http.StatusForbidden, http.StatusText(http.StatusForbidden)) // 禁止访问 )
View Source
var ( ErrInputParamsInvalid ClientErrorCode = "input.paramsInvalid" // 参数错误 ErrDataDuplicate ServerErrorCode = "data.duplicate" // 数据重复 ErrDataExists ServerErrorCode = "data.exists" // 数据已存在 ErrDataNoFound ServerErrorCode = "data.notFound" // 数据不存在 ErrAuthAccessTokenInvalid ClientErrorCode = "auth.accessTokenInvalid" // 访问令牌错误 ErrAuthLoginFail ServerErrorCode = "auth.loginFail" // 登录失败 ErrAuthRefreshTokenInvalid ServerErrorCode = "auth.refreshTokenInvalid" // 刷新令牌失败 )
Functions ¶
func CheckPassword ¶
func CheckUploadToken ¶
func CreateCaptcha ¶
func CreatePassword ¶
func CreateUploadToken ¶
func EnsureCountNoError ¶
func EnsureFound ¶ added in v1.0.48
func EnsureFound(value any)
func EnsureFoundNoError ¶
func EnsureNoError ¶
func EnsureNoError(err error)
func FormatEmail ¶
func FormatPhone ¶
func GetEnvBool ¶
func GetEnvBoolDefault ¶
func GetEnvDefault ¶
func GetEnvIntDefault ¶
func InitSnowflake ¶
func IntToStrWithPad ¶ added in v1.0.50
func MakeUploadHash ¶
func RandomChar ¶ added in v1.0.46
func RandomCharset ¶ added in v1.0.46
func RandomNumber ¶ added in v1.0.46
func RandomString ¶ added in v1.0.46
func ResolveCmd ¶
func SliceExchange ¶ added in v1.0.50
func SliceExchange[T any, V any](s []T, exchanger SliceExchangRunner[T, V]) []V
func SliceFilter ¶ added in v1.0.50
func SliceFilter[T any](s []T, filter SliceFilterRunner[T]) []T
func SnowWithPrefix ¶
func SortSlice ¶ added in v1.0.50
func SortSlice[T any](list []T, cmp SortCompare[T])
func SortSliceStable ¶ added in v1.0.50
func SortSliceStable[T any](list []T, cmp SortCompare[T])
func SpawnSimple ¶
func SqlDeleted ¶
func SqlDeleted() string
func SqlNotDeleted ¶
func SqlNotDeleted() string
func SqlWhereEq ¶
func SqlWhereGt ¶
func SqlWhereIsNull ¶
func SqlWhereLike ¶
func SqlWherePrefix ¶
func WithRecover ¶
Types ¶
type AnySlice ¶ added in v1.0.50
func (AnySlice[T, V]) Exchange ¶ added in v1.0.50
func (s AnySlice[T, V]) Exchange(exchanger SliceExchangRunner[T, V]) []V
func (AnySlice[T, V]) Filter ¶ added in v1.0.50
func (s AnySlice[T, V]) Filter(filter SliceFilterRunner[T]) AnySlice[T, V]
type AnySort ¶ added in v1.0.50
func (AnySort[T, V]) SortSlice ¶ added in v1.0.50
func (s AnySort[T, V]) SortSlice(sc SortCompare[T])
func (AnySort[T, V]) SortSlicePeek ¶ added in v1.0.50
func (AnySort[T, V]) SortSliceStable ¶ added in v1.0.50
func (s AnySort[T, V]) SortSliceStable(sc SortCompare[T])
func (AnySort[T, V]) SortSliceStablePeek ¶ added in v1.0.50
type Array ¶
type Array[T any] []T
数组定义
func GetDbStructKeys ¶
func GetStructKeys ¶
func GetXormStructKeys ¶
type ClientErrorCode ¶
type ClientErrorCode string
客户端错误
func (ClientErrorCode) Error ¶
func (code ClientErrorCode) Error() *Error
func (ClientErrorCode) Panic ¶
func (code ClientErrorCode) Panic()
func (ClientErrorCode) PanicError ¶
func (code ClientErrorCode) PanicError(err error)
type DeleteStatus ¶
type DeleteStatus int8
const ( DeleteStatusDefault DeleteStatus = 0 DeleteStatusDeleted DeleteStatus = 1 DeleteStatusDroped DeleteStatus = 2 )
type EnvGetter ¶
type EnvGetter struct { Key EnvKey // contains filtered or unexported fields }
func GetterDefault ¶
type Error ¶
type Error struct { StatusCode int `json:"-"` Code string `json:"code"` Message string `json:"message"` Stack error `json:"-"` }
错误
func ClientError ¶
func ClientError(code ClientErrorCode) *Error
func ServerError ¶
func ServerError(code ServerErrorCode) *Error
func (*Error) PanicError ¶
func (*Error) WithMessage ¶
type PageInfo ¶
type ServerErrorCode ¶
type ServerErrorCode string
服务端错误
func (ServerErrorCode) Error ¶
func (code ServerErrorCode) Error() *Error
func (ServerErrorCode) Panic ¶
func (code ServerErrorCode) Panic()
func (ServerErrorCode) PanicError ¶
func (code ServerErrorCode) PanicError(err error)
type SimpleArray ¶ added in v1.0.51
type SimpleArray[T SimpleType] []T
func (*SimpleArray[T]) Concat ¶ added in v1.0.51
func (arr *SimpleArray[T]) Concat(next SimpleArray[T])
func (SimpleArray[T]) Contains ¶ added in v1.0.51
func (arr SimpleArray[T]) Contains(e T) bool
func (*SimpleArray[T]) Delete ¶ added in v1.0.51
func (arr *SimpleArray[T]) Delete(e T) bool
func (SimpleArray[T]) DeleteMany ¶ added in v1.0.51
func (arr SimpleArray[T]) DeleteMany(e T) int
func (SimpleArray[T]) Filter ¶ added in v1.0.51
func (arr SimpleArray[T]) Filter(f func(T) bool) SimpleArray[T]
func (SimpleArray[T]) ForEach ¶ added in v1.0.51
func (arr SimpleArray[T]) ForEach(f func(e T))
func (SimpleArray[T]) IndexOf ¶ added in v1.0.51
func (arr SimpleArray[T]) IndexOf(e T) int
func (*SimpleArray[T]) Insert ¶ added in v1.0.51
func (arr *SimpleArray[T]) Insert(i int, e ...T)
func (SimpleArray[T]) Join ¶ added in v1.0.51
func (arr SimpleArray[T]) Join(sep string) string
func (SimpleArray[T]) LastIndexOf ¶ added in v1.0.51
func (arr SimpleArray[T]) LastIndexOf(e T) int
func (SimpleArray[T]) Map ¶ added in v1.0.51
func (arr SimpleArray[T]) Map(f func(T) T) SimpleArray[T]
func (*SimpleArray[T]) Push ¶ added in v1.0.51
func (arr *SimpleArray[T]) Push(e ...T)
func (*SimpleArray[T]) Remove ¶ added in v1.0.51
func (arr *SimpleArray[T]) Remove(i int)
func (*SimpleArray[T]) Unshift ¶ added in v1.0.51
func (arr *SimpleArray[T]) Unshift(e ...T)
type SimpleType ¶ added in v1.0.51
type SliceExchangRunner ¶ added in v1.0.50
type SliceFilterRunner ¶ added in v1.0.50
type SortCompare ¶ added in v1.0.50
type SpawnOptions ¶
type SpawnOptions struct { // 使用程序std输入输入 SystemStdout bool }
type SqlFieldType ¶ added in v1.0.8
type SqlFieldType string
func Field ¶ added in v1.0.8
func Field(field string) SqlFieldType
func (SqlFieldType) IsNull ¶ added in v1.0.8
func (s SqlFieldType) IsNull() string
func (SqlFieldType) NotIsNull ¶ added in v1.0.8
func (s SqlFieldType) NotIsNull() string
func (SqlFieldType) OrderAsc ¶ added in v1.0.8
func (s SqlFieldType) OrderAsc() string
xorm.OrderBy field asc
func (SqlFieldType) OrderDesc ¶ added in v1.0.8
func (s SqlFieldType) OrderDesc() string
xorm.OrderBy field desc
Click to show internal directories.
Click to hide internal directories.