Documentation ¶
Index ¶
- Variables
- func ArrayEmpty[T any](array []T) (slice []any)
- func ArrayFilter(array []string) (slice []string)
- func ArrayMapWithField(array []map[string]any, field any) (slice []any)
- func ArrayRemove(array []string, args ...string) []string
- func ArrayReverse[T any](array []T) (slice []T)
- func ArrayUnique[T any](array []T) (slice []any)
- func Calc(input any) (output float64)
- func Caller() *caller
- func CustomProcessApi(url string, api string) (result string)
- func Default[T any](param T, value ...T) (result T)
- func EnvToml(args ...string) (result any)
- func ForMap[T any](slice []T, fun func(item T) (result T)) (newSlice []T)
- func GetCaller() (funcName string, fileName string, line int)
- func InArray[T any](value T, array []T) (ok bool)
- func InMapKey(key string, array map[string]any) bool
- func InMapValue(value any, array map[string]string) bool
- func MapKeys[T map[string]any](data T) (result []string)
- func MapMerge(map1 map[any]any, map2 map[any]any) map[any]any
- func MapMergeString(map1 map[string]string, map2 map[string]string) map[string]string
- func MapToURL(params map[string]any) (result string)
- func MapValues[T map[string]any](data T) (result []any)
- func MapWithField[T map[string]any](data T, field []string) (result T)
- func MapWithoutField[T map[string]any](data T, field []string) (result T)
- func Redirect(url any) (result string)
- func Replace(value any, params map[string]any) (result string)
- func Ternary[T any](IF bool, TRUE T, FALSE T) T
- func ValidateRules(name string, value any, rule string, message map[string]string) (err error)
- type AESRequest
- type AESResponse
- type AsyncStruct
- type CurlRequest
- type CurlResponse
- type CurlStruct
- func (this *CurlStruct) Body(body any) *CurlStruct
- func (this *CurlStruct) Client(client *http.Client) *CurlStruct
- func (this *CurlStruct) Data(key string, value any) *CurlStruct
- func (this *CurlStruct) Datas(data map[string]any) *CurlStruct
- func (this *CurlStruct) Delete(url string) *CurlStruct
- func (this *CurlStruct) Get(url string) *CurlStruct
- func (this *CurlStruct) Header(key any, value any) *CurlStruct
- func (this *CurlStruct) Headers(headers map[string]any) *CurlStruct
- func (this *CurlStruct) Method(method string) *CurlStruct
- func (this *CurlStruct) Patch(url string) *CurlStruct
- func (this *CurlStruct) Post(url string) *CurlStruct
- func (this *CurlStruct) Put(url string) *CurlStruct
- func (this *CurlStruct) Query(key any, value any) *CurlStruct
- func (this *CurlStruct) Querys(params map[string]any) *CurlStruct
- func (this *CurlStruct) Send() *CurlResponse
- func (this *CurlStruct) Url(url string) *CurlStruct
- type EnvModel
- type FileCacheClient
- func (this *FileCacheClient) Clear() (ok bool)
- func (this *FileCacheClient) ClearE() (err error)
- func (this *FileCacheClient) Del(key any) (ok bool)
- func (this *FileCacheClient) DelE(key any) (err error)
- func (this *FileCacheClient) DelPrefix(prefix ...any) (ok bool)
- func (this *FileCacheClient) DelPrefixE(prefix ...any) (err error)
- func (this *FileCacheClient) DelTags(tags ...any) (ok bool)
- func (this *FileCacheClient) DelTagsE(tag ...any) (err error)
- func (this *FileCacheClient) Get(key any) (result []byte)
- func (this *FileCacheClient) GetInfo(key any) (info map[string]any)
- func (this *FileCacheClient) GetKeys() (slice []string)
- func (this *FileCacheClient) Has(key any) (exist bool)
- func (this *FileCacheClient) Set(key any, value []byte, expire ...any) (ok bool)
- func (this *FileCacheClient) SetE(key any, value []byte, expire int64) (err error)
- type FileCacheClientItem
- type FileRequest
- type FileResponse
- type FileStruct
- func (this *FileStruct) Byte(path ...any) (result *FileResponse)
- func (this *FileStruct) Dir(dir any) *FileStruct
- func (this *FileStruct) DirInfo(dir ...any) (result *FileResponse)
- func (this *FileStruct) Domain(domain any) *FileStruct
- func (this *FileStruct) Download(path ...any) (result *FileResponse)
- func (this *FileStruct) EnZip() (result *FileResponse)
- func (this *FileStruct) Exist(path ...any) (ok bool)
- func (this *FileStruct) Ext(ext any) *FileStruct
- func (this *FileStruct) Limit(limit any) *FileStruct
- func (this *FileStruct) Line(path ...any) (result *FileResponse)
- func (this *FileStruct) List(path ...any) (result *FileResponse)
- func (this *FileStruct) Name(name any) *FileStruct
- func (this *FileStruct) Page(page any) *FileStruct
- func (this *FileStruct) Path(path any) *FileStruct
- func (this *FileStruct) Prefix(prefix any) *FileStruct
- func (this *FileStruct) Remove(path ...any) (result *FileResponse)
- func (this *FileStruct) Rename(path ...any) (result *FileResponse)
- func (this *FileStruct) Save(reader io.Reader, path ...string) (result *FileResponse)
- func (this *FileStruct) UnZip() (result *FileResponse)
- type FormatStruct
- type GetStruct
- type HashStruct
- type IsStruct
- func (this *IsStruct) Accepted(value any) (ok bool)
- func (this *IsStruct) ActiveUrl(value any) (ok bool)
- func (this *IsStruct) Alpha(value any) (ok bool)
- func (this *IsStruct) AlphaDash(value any) (ok bool)
- func (this *IsStruct) AlphaNum(value any) (ok bool)
- func (this *IsStruct) Array(value any) (ok bool)
- func (this *IsStruct) Bool(value any) (ok bool)
- func (this *IsStruct) Chs(value any) (ok bool)
- func (this *IsStruct) ChsAlpha(value any) (ok bool)
- func (this *IsStruct) ChsAlphaNum(value any) (ok bool)
- func (this *IsStruct) ChsDash(value any) (ok bool)
- func (this *IsStruct) Cntrl(value any) (ok bool)
- func (this *IsStruct) Date(date any) (ok bool)
- func (this *IsStruct) Domain(domain any) (ok bool)
- func (this *IsStruct) Email(email any) (ok bool)
- func (this *IsStruct) Empty(value any) (ok bool)
- func (this *IsStruct) False(value any) (ok bool)
- func (this *IsStruct) Float(value any) (ok bool)
- func (this *IsStruct) Graph(value any) (ok bool)
- func (this *IsStruct) IdCard(value any) (ok bool)
- func (this *IsStruct) Ip(ip any) (ok bool)
- func (this *IsStruct) JsonString(value any) (ok bool)
- func (this *IsStruct) Lower(value any) (ok bool)
- func (this *IsStruct) MacAddr(value any) (ok bool)
- func (this *IsStruct) Map(value any) (ok bool)
- func (this *IsStruct) MapAny(value any) (ok bool)
- func (this *IsStruct) Mobile(value any) (ok bool)
- func (this *IsStruct) Number(value any) (ok bool)
- func (this *IsStruct) Phone(phone any) (ok bool)
- func (this *IsStruct) Slice(value any) (ok bool)
- func (this *IsStruct) SliceSlice(value any) (ok bool)
- func (this *IsStruct) Space(value any) (ok bool)
- func (this *IsStruct) String(value any) (ok bool)
- func (this *IsStruct) True(value any) (ok bool)
- func (this *IsStruct) Upper(value any) (ok bool)
- func (this *IsStruct) Url(url any) (ok bool)
- func (this *IsStruct) Xdigit(value any) (ok bool)
- func (this *IsStruct) Zip(value any) (ok bool)
- type JsonStruct
- func (this *JsonStruct) Decode(data any) (result any)
- func (this *JsonStruct) Encode(data any) (result string)
- func (this *JsonStruct) Get(jsonString any, key any) (result any, err error)
- func (this *JsonStruct) String(data any) (result string)
- func (this *JsonStruct) Unmarshal(data []byte, result any) (err error)
- func (this *JsonStruct) Valid(data any) (result bool)
- type LangModel
- type MimeStruct
- type NetStruct
- type ParseStruct
- type PasswordStruct
- type RSAResponse
- type RSAStruct
- type RandStruct
- func (this *RandStruct) Int(max any, min ...any) (result int)
- func (this *RandStruct) MapSlice(slice []map[string]any) (result []map[string]any)
- func (this *RandStruct) Number(length any) (result string)
- func (this *RandStruct) Slice(slice []any, limit any) (result []any)
- func (this *RandStruct) String(length any, chars ...string) (result string)
- type StructStruct
- func (this *StructStruct) Del(obj any, key string)
- func (this *StructStruct) Get(obj any, key string) (result any)
- func (this *StructStruct) Has(obj any, key string) (ok bool)
- func (this *StructStruct) Keys(obj any) (slice []string)
- func (this *StructStruct) Len(obj any) (length int)
- func (this *StructStruct) Map(obj any) (result map[string]any)
- func (this *StructStruct) Set(obj any, key string, val any)
- func (this *StructStruct) Slice(obj any) (slice []any)
- func (this *StructStruct) Values(obj any) (slice []any)
- type UnityStruct
- type VersionStruct
- type ViperModel
- type ViperResponse
Constants ¶
This section is empty.
Variables ¶
var Array struct { Filter func(array []string) (slice []string) Remove func(array []string, args ...string) (slice []string) Unique func(array []any) (slice []any) Empty func(array []any) (slice []any) Reverse func(array []any) (slice []any) MapWithField func(array []map[string]any, field any) (slice []any) }
var In struct { Array func(value any, array []any) (ok bool) }
var Map struct { WithField func(data map[string]any, field []string) (result map[string]any) WithoutField func(data map[string]any, field []string) (result map[string]any) ToURL func(data map[string]any) (result string) Keys func(data map[string]any) (result []string) Values func(data map[string]any) (result []any) }
var MimeMap = map[string]string{
"js": "application/javascript",
"json": "application/json",
"xml": "application/xml",
"css": "text/css",
"html": "text/html",
"txt": "text/plain",
"gif": "image/gif",
"png": "image/png",
"jpg": "image/jpeg",
"jpeg": "image/jpeg",
"svg": "image/svg+xml",
"ico": "image/x-icon",
"pdf": "application/pdf",
"zip": "application/zip",
"rar": "application/x-rar-compressed",
"gz": "application/x-gzip",
"tar": "application/x-tar",
"7z": "application/x-7z-compressed",
"mp3": "audio/mpeg",
"mp4": "video/mp4",
"avi": "video/x-msvideo",
"doc": "application/msword",
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"xls": "application/vnd.ms-excel",
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"ppt": "application/vnd.ms-powerpoint",
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
"csv": "text/csv",
"md": "text/markdown",
}
var Validate = func(model any) *validator { return &validator{ model: model, rule: ValidateRules, } }
Validate - 验证器入口
Functions ¶
func ArrayMapWithField ¶ added in v1.2.6
ArrayMapWithField - 数组Map保留指定字段
func ArrayReverse ¶ added in v1.3.3
func ArrayReverse[T any](array []T) (slice []T)
ArrayReverse - 数组反转
func ArrayUnique ¶ added in v1.1.2
ArrayUnique - 数组去重
func CustomProcessApi ¶
func ForMap ¶ added in v1.0.8
func ForMap[T any](slice []T, fun func(item T) (result T)) (newSlice []T)
ForMap - 遍历数组,返回新数组
func MapMergeString ¶
MapMergeString map合并
func MapWithField ¶ added in v1.1.4
MapWithField - 从map中提取指定字段
func MapWithoutField ¶ added in v1.1.4
MapWithoutField - 从map中排除指定字段
func ValidateRules ¶
ValidateRules - 验证规则 *
- @rule - 内置规则 - 如下:
- required:必填
- min:最小值
- max:最大值
- email:是否为邮箱
- number:是否为数字
- float:是否为浮点数
- bool:是否为布尔值
- slice:是否为切片 - (数组)
- jsonStr:是否为 JSON 字符串
- accepted:验证某个字段是否为为 yes, on, 或是 1
- date:是否为日期
- alpha:只能包含字母
- alphaNum:只能包含字母和数字
- alphaDash:只能包含字母、数字和下划线_及破折号-
- chs:只能包含汉字
- chsAlpha:只能包含汉字、字母
- chsAlphaNum:只能包含汉字、字母和数字
- chsDash:只能是汉字、字母、数字和下划线_及破折号-
- cntrl:是否为控制字符 - (换行、缩进、空格)
- graph:是否为可见字符 - (除空格外的所有可打印字符)
- lower:是否为小写字母
- upper:是否为大写字母
- space:是否为空白字符 - (空格、制表符、换页符等)
- xdigit:是否为十六进制字符 - (0-9、a-f、A-F)
- activeUrl:是否为有效的域名或者IP
- url:是否为有效的URL地址
- ip:是否为IP地址
- mobile:是否为手机号
- idCard:是否为身份证号
- MacAddr:是否为MAC地址
- zip:是否为邮政编码 *
Types ¶
type AESRequest ¶ added in v1.2.3
AESRequest - 请求输入
func (*AESRequest) Decrypt ¶ added in v1.2.3
func (this *AESRequest) Decrypt(text any) (result *AESResponse)
Decrypt 解密
func (*AESRequest) Encrypt ¶ added in v1.2.3
func (this *AESRequest) Encrypt(text any) (result *AESResponse)
Encrypt 加密
type AESResponse ¶ added in v1.2.3
AESResponse - 响应输出
type AsyncStruct ¶
type CurlRequest ¶
type CurlRequest struct { Body any Url string Method string Client *http.Client Data map[string]any Query map[string]any Headers map[string]any }
CurlRequest - 发起请求的结构体
type CurlResponse ¶
type CurlResponse struct { StatusCode int Request *http.Request Headers *http.Header Body *io.ReadCloser Byte []byte Text string Json map[string]any Error error }
CurlResponse - 响应的结构体
type CurlStruct ¶
type CurlStruct struct {
// contains filtered or unexported fields
}
CurlStruct - Curl 结构体
func (*CurlStruct) Client ¶
func (this *CurlStruct) Client(client *http.Client) *CurlStruct
Client - 定义请求客户端
func (*CurlStruct) Data ¶
func (this *CurlStruct) Data(key string, value any) *CurlStruct
Data - 定义请求数据
func (*CurlStruct) Datas ¶
func (this *CurlStruct) Datas(data map[string]any) *CurlStruct
Datas - 批量定义请求数据
func (*CurlStruct) Delete ¶
func (this *CurlStruct) Delete(url string) *CurlStruct
Delete - 发起 DELETE 请求
func (*CurlStruct) Header ¶
func (this *CurlStruct) Header(key any, value any) *CurlStruct
Header - 定义请求头
func (*CurlStruct) Headers ¶
func (this *CurlStruct) Headers(headers map[string]any) *CurlStruct
Headers - 批量定义请求头
func (*CurlStruct) Method ¶
func (this *CurlStruct) Method(method string) *CurlStruct
Method - 定义请求类型 - 默认 GET
func (*CurlStruct) Patch ¶
func (this *CurlStruct) Patch(url string) *CurlStruct
Patch - 发起 PATCH 请求
func (*CurlStruct) Query ¶
func (this *CurlStruct) Query(key any, value any) *CurlStruct
Query - 定义请求参数
func (*CurlStruct) Querys ¶
func (this *CurlStruct) Querys(params map[string]any) *CurlStruct
Querys - 批量定义请求参数
type FileCacheClient ¶ added in v1.2.2
type FileCacheClient struct {
// contains filtered or unexported fields
}
func NewFileCache ¶ added in v1.2.1
func NewFileCache(dir any, expire any, prefix ...any) (*FileCacheClient, error)
NewFileCache - 新建文件缓存 *
- @param dir 缓存目录
- @param prefix 缓存名前缀
- @return *FileCacheClient, error
- @example:
- 1. cache, err := facade.NewFileCacheClient("runtime/cache")
- 2. cache, err := facade.NewFileCacheClient("runtime/cache", "cache_")
func (*FileCacheClient) Clear ¶ added in v1.2.2
func (this *FileCacheClient) Clear() (ok bool)
Clear 清空缓存
func (*FileCacheClient) ClearE ¶ added in v1.2.2
func (this *FileCacheClient) ClearE() (err error)
ClearE 清空缓存
func (*FileCacheClient) Del ¶ added in v1.2.2
func (this *FileCacheClient) Del(key any) (ok bool)
Del 从缓存中删除key对应的数据
func (*FileCacheClient) DelE ¶ added in v1.2.2
func (this *FileCacheClient) DelE(key any) (err error)
DelE 从缓存中删除key对应的数据
func (*FileCacheClient) DelPrefix ¶ added in v1.2.2
func (this *FileCacheClient) DelPrefix(prefix ...any) (ok bool)
DelPrefix 从缓存中删除指定前缀的数据
func (*FileCacheClient) DelPrefixE ¶ added in v1.2.2
func (this *FileCacheClient) DelPrefixE(prefix ...any) (err error)
DelPrefixE 删除指定前缀的缓存
func (*FileCacheClient) DelTags ¶ added in v1.2.2
func (this *FileCacheClient) DelTags(tags ...any) (ok bool)
DelTags 从缓存中删除指定标签的数据
func (*FileCacheClient) DelTagsE ¶ added in v1.2.2
func (this *FileCacheClient) DelTagsE(tag ...any) (err error)
DelTagsE 删除指定标签的缓存
func (*FileCacheClient) Get ¶ added in v1.2.2
func (this *FileCacheClient) Get(key any) (result []byte)
Get 从缓存中获取key对应的数据
func (*FileCacheClient) GetInfo ¶ added in v1.2.2
func (this *FileCacheClient) GetInfo(key any) (info map[string]any)
GetInfo 获取缓存信息
func (*FileCacheClient) GetKeys ¶ added in v1.2.2
func (this *FileCacheClient) GetKeys() (slice []string)
GetKeys 获取所有缓存的key
func (*FileCacheClient) Has ¶ added in v1.2.2
func (this *FileCacheClient) Has(key any) (exist bool)
Has 检查缓存中是否存在key对应的数据
type FileCacheClientItem ¶ added in v1.2.2
type FileCacheClientItem struct {
// contains filtered or unexported fields
}
type FileRequest ¶ added in v1.0.5
type FileRequest struct { // 文件名 Name string // 文件路径(包含文件名) Path string // 目录路径(不包含文件名) Dir string // 文件后缀 Ext string // 限制行数 Limit int // 读取偏移量 Page int // 返回结果格式 Format string // 是否包含子目录 Sub bool // 域名 - 用于拼接文件路径 Domain string // 前缀 - 用于过滤前缀 Prefix string }
FileRequest - File 请求
type FileResponse ¶ added in v1.0.5
FileResponse - File 响应
type FileStruct ¶ added in v1.0.5
type FileStruct struct {
// contains filtered or unexported fields
}
FileStruct - File 结构体
func (*FileStruct) Byte ¶ added in v1.0.5
func (this *FileStruct) Byte(path ...any) (result *FileResponse)
Byte 获取文件字节
func (*FileStruct) Dir ¶ added in v1.0.6
func (this *FileStruct) Dir(dir any) *FileStruct
Dir 设置目录路径(不包含文件名,如:/tmp)
func (*FileStruct) DirInfo ¶ added in v1.1.8
func (this *FileStruct) DirInfo(dir ...any) (result *FileResponse)
DirInfo 获取目录信息
func (*FileStruct) Domain ¶ added in v1.0.8
func (this *FileStruct) Domain(domain any) *FileStruct
Domain 设置域名(用于拼接文件路径)
func (*FileStruct) Download ¶ added in v1.1.7
func (this *FileStruct) Download(path ...any) (result *FileResponse)
Download 下载文件 *
- @param path1 远程文件路径(下载地址)
- @param path2 本地文件路径(保存路径,包含文件名)
- @return *FileResponse
- @example:
- 1. item := utils.File().Download("https://inis.cn/name.zip", "public/test.zip")
- 2. item := utils.File().Dir("public").Name("test.zip").Download("https://inis.cn/name.zip")
- 3. item := utils.File(utils.FileRequest{ Path: "https://inis.cn/name.zip", Name: "test.zip", Dir: "public", }).Download()
func (*FileStruct) EnZip ¶ added in v1.1.8
func (this *FileStruct) EnZip() (result *FileResponse)
EnZip 压缩文件 *
- @return *FileResponse
- @example:
- 1. item := utils.File().Dir("public").Name("name.zip").EnZip()
- 2. item := utils.File().Dir("public").Path("public/name.zip").EnZip()
- 3. item := utils.File(utils.FileRequest{ Path: "public/name.zip", Dir: "public", }).EnZip()
func (*FileStruct) Exist ¶ added in v1.1.5
func (this *FileStruct) Exist(path ...any) (ok bool)
Exist 判断文件是否存在
func (*FileStruct) Ext ¶ added in v1.0.5
func (this *FileStruct) Ext(ext any) *FileStruct
Ext 设置文件后缀(如:.txt)
func (*FileStruct) Limit ¶ added in v1.0.7
func (this *FileStruct) Limit(limit any) *FileStruct
Limit 设置限制行数
func (*FileStruct) Line ¶ added in v1.0.7
func (this *FileStruct) Line(path ...any) (result *FileResponse)
Line 按行读取文件
func (*FileStruct) List ¶ added in v1.0.6
func (this *FileStruct) List(path ...any) (result *FileResponse)
List 获取指定目录下的所有文件
func (*FileStruct) Name ¶ added in v1.0.5
func (this *FileStruct) Name(name any) *FileStruct
Name 设置文件名(不包含路径,如:test.txt)
func (*FileStruct) Page ¶ added in v1.0.7
func (this *FileStruct) Page(page any) *FileStruct
Page 设置读取偏移量
func (*FileStruct) Path ¶ added in v1.0.5
func (this *FileStruct) Path(path any) *FileStruct
Path 设置文件路径(包含文件名,如:/tmp/test.txt)
func (*FileStruct) Prefix ¶ added in v1.0.8
func (this *FileStruct) Prefix(prefix any) *FileStruct
Prefix 设置前缀(用于过滤前缀)
func (*FileStruct) Remove ¶ added in v1.1.5
func (this *FileStruct) Remove(path ...any) (result *FileResponse)
Remove 删除文件或目录
func (*FileStruct) Rename ¶ added in v1.3.2
func (this *FileStruct) Rename(path ...any) (result *FileResponse)
Rename 重命名文件
func (*FileStruct) Save ¶ added in v1.0.5
func (this *FileStruct) Save(reader io.Reader, path ...string) (result *FileResponse)
Save 保存文件
func (*FileStruct) UnZip ¶ added in v1.1.8
func (this *FileStruct) UnZip() (result *FileResponse)
UnZip 解压文件 *
- @return *FileResponse
- @example:
- 1. item := utils.File().Dir("public").Name("name.zip").UnZip()
- 2. item := utils.File().Dir("public").Path("public/name.zip").UnZip()
- 3. item := utils.File(utils.FileRequest{ Path: "public/name.zip", Dir: "public", }).UnZip()
type FormatStruct ¶ added in v1.3.0
type FormatStruct struct{}
var Format *FormatStruct
func (*FormatStruct) Query ¶ added in v1.3.0
func (this *FormatStruct) Query(data any) (result string)
Query 转 Query 格式
type GetStruct ¶ added in v1.3.0
type GetStruct struct{}
var Get *GetStruct
Get - 获取
type HashStruct ¶ added in v1.2.3
type HashStruct struct{}
var Hash *HashStruct
Hash - 哈希加密
func (*HashStruct) Number ¶ added in v1.3.0
func (this *HashStruct) Number(length any) (result string)
Number 生成指定长度的随机数 *
- @param length 长度
- @return result 随机数
- @example:
- 1. number := facade.Hash.Number(6)
func (*HashStruct) Sum32 ¶ added in v1.2.3
func (this *HashStruct) Sum32(text any) (result string)
Sum32 - 哈希加密
func (*HashStruct) Token ¶ added in v1.2.3
func (this *HashStruct) Token(value any, args ...any) (result string)
Token 生成指定长度的指纹令牌 *
- @param value 值
- @param args 参数
- @param args[0] 令牌长度,默认长度为 16
- @param args[1] 令牌前缀,默认前缀为 token
- @return result 令牌
- @example:
- 1. token := facade.Hash.Token("test")
- 2. token := facade.Hash.Token("test", 32, "token")
type IsStruct ¶ added in v1.3.0
type IsStruct struct{}
var Is *IsStruct
Is - 是否为
func (*IsStruct) ChsAlphaNum ¶ added in v1.3.0
ChsAlphaNum - 只能是汉字、字母和数字
func (*IsStruct) JsonString ¶ added in v1.3.0
JsonString - 是否为json字符串
func (*IsStruct) SliceSlice ¶ added in v1.3.0
SliceSlice - 是否为二维切片
type JsonStruct ¶ added in v1.3.0
type JsonStruct struct{}
var Json *JsonStruct
Json - JSON 处理
func (*JsonStruct) Decode ¶ added in v1.3.0
func (this *JsonStruct) Decode(data any) (result any)
Decode 解码
func (*JsonStruct) Encode ¶ added in v1.3.0
func (this *JsonStruct) Encode(data any) (result string)
Encode 编码
func (*JsonStruct) Get ¶ added in v1.3.0
func (this *JsonStruct) Get(jsonString any, key any) (result any, err error)
Get 获取json中的值 - 支持多级
func (*JsonStruct) String ¶ added in v1.3.0
func (this *JsonStruct) String(data any) (result string)
String map转json字符串
func (*JsonStruct) Unmarshal ¶ added in v1.3.4
func (this *JsonStruct) Unmarshal(data []byte, result any) (err error)
Unmarshal 解码
func (*JsonStruct) Valid ¶ added in v1.3.4
func (this *JsonStruct) Valid(data any) (result bool)
Valid - 验证JSON数据
type MimeStruct ¶ added in v1.3.0
type MimeStruct struct{}
var Mime *MimeStruct
func (*MimeStruct) Type ¶ added in v1.3.0
func (this *MimeStruct) Type(suffix any) (mime string)
Type 获取后缀对应的 mime
type ParseStruct ¶ added in v1.3.0
type ParseStruct struct{}
var Parse *ParseStruct
Parse - 解析
func (*ParseStruct) Domain ¶ added in v1.3.0
func (this *ParseStruct) Domain(value any) (domain string)
Domain - 解析域名
func (*ParseStruct) Params ¶ added in v1.3.0
func (this *ParseStruct) Params(params map[string]any) (result map[string]any)
Params - 解析参数 把 Content-Type = application/x-www-form-urlencoded 的参数解析成 map[string]any
func (*ParseStruct) ParamsBefore ¶ added in v1.3.0
func (this *ParseStruct) ParamsBefore(params url.Values) (result map[string]any)
ParamsBefore - 解析参数 把 Content-Type = application/x-www-form-urlencoded 的参数解析成 object.deep.age = 10 的格式
type PasswordStruct ¶ added in v1.3.0
type PasswordStruct struct{}
var Password *PasswordStruct
Password - 密码
func (*PasswordStruct) Create ¶ added in v1.3.0
func (this *PasswordStruct) Create(password any) (result string)
Create - 创建密码
type RSAResponse ¶ added in v1.2.3
type RSAStruct ¶ added in v1.2.3
type RSAStruct struct{}
var RSA *RSAStruct
func (*RSAStruct) Decrypt ¶ added in v1.2.3
func (this *RSAStruct) Decrypt(privateKey, text string) (result *RSAResponse)
Decrypt 解密
func (*RSAStruct) Encrypt ¶ added in v1.2.3
func (this *RSAStruct) Encrypt(publicKey, text string) (result *RSAResponse)
Encrypt 加密
func (*RSAStruct) Generate ¶ added in v1.2.3
func (this *RSAStruct) Generate(bits any) (result *RSAResponse)
Generate 生成 RSA 密钥对
type RandStruct ¶ added in v1.3.0
type RandStruct struct{}
var Rand *RandStruct
Rand - 随机数
func (*RandStruct) Int ¶ added in v1.3.0
func (this *RandStruct) Int(max any, min ...any) (result int)
Int - 生成随机整数
func (*RandStruct) MapSlice ¶ added in v1.3.0
func (this *RandStruct) MapSlice(slice []map[string]any) (result []map[string]any)
MapSlice - 打乱切片顺序
func (*RandStruct) Number ¶ added in v1.3.0
func (this *RandStruct) Number(length any) (result string)
Number - 生成指定长度的随机数
type StructStruct ¶ added in v1.3.0
type StructStruct struct{}
var Struct *StructStruct
Struct - 操作结构体
func (*StructStruct) Del ¶ added in v1.3.0
func (this *StructStruct) Del(obj any, key string)
Del - 删除结构体的字段
func (*StructStruct) Get ¶ added in v1.3.0
func (this *StructStruct) Get(obj any, key string) (result any)
Get - 动态获取结构体的值
func (*StructStruct) Has ¶ added in v1.3.0
func (this *StructStruct) Has(obj any, key string) (ok bool)
Has - 判断结构体是否存在某个字段
func (*StructStruct) Keys ¶ added in v1.3.0
func (this *StructStruct) Keys(obj any) (slice []string)
Keys - 获取结构体的字段
func (*StructStruct) Len ¶ added in v1.3.0
func (this *StructStruct) Len(obj any) (length int)
Len - 获取结构体的长度
func (*StructStruct) Map ¶ added in v1.3.0
func (this *StructStruct) Map(obj any) (result map[string]any)
Map - 将结构体转换为map
func (*StructStruct) Set ¶ added in v1.3.0
func (this *StructStruct) Set(obj any, key string, val any)
Set - 动态给结构体赋值
func (*StructStruct) Slice ¶ added in v1.3.0
func (this *StructStruct) Slice(obj any) (slice []any)
Slice - 将结构体转换为切片
func (*StructStruct) Values ¶ added in v1.3.0
func (this *StructStruct) Values(obj any) (slice []any)
Values - 获取结构体的值
type UnityStruct ¶ added in v1.3.0
type UnityStruct struct{}
var Unity *UnityStruct
Unity - 统一规范化
func (*UnityStruct) Ids ¶ added in v1.3.0
func (this *UnityStruct) Ids(param ...any) (ids []any)
Ids 参数归一化
type VersionStruct ¶ added in v1.3.0
type VersionStruct struct{}
var Version *VersionStruct
Version - 版本
func (*VersionStruct) Compare ¶ added in v1.3.0
func (this *VersionStruct) Compare(v1, v2 any) (result int)
Compare - 版本号比对 *
- @param v1 string - 小版本号
- @param v2 string - 大版本号
- @return int - 0: 相等,1: v1 < v2,-1: v1 > v2
- @example:
- utils.Version.Compare("1.2.0", "1.0.0") // 1
func (*VersionStruct) Go ¶ added in v1.3.0
func (this *VersionStruct) Go() (result string)
Go - 获取当前go版本号
type ViperModel ¶ added in v1.0.1
type ViperModel struct { // 配置文件路径 Path string // 配置文件类型 Mode string // 文件名 Name string // 文件内容 Content string }
func Viper ¶ added in v1.0.1
func Viper(model ...ViperModel) *ViperModel
func (*ViperModel) Read ¶ added in v1.0.1
func (this *ViperModel) Read() (result ViperResponse)
func (*ViperModel) SetMode ¶ added in v1.0.1
func (this *ViperModel) SetMode(mode string) *ViperModel
func (*ViperModel) SetName ¶ added in v1.0.1
func (this *ViperModel) SetName(name string) *ViperModel
func (*ViperModel) SetPath ¶ added in v1.0.1
func (this *ViperModel) SetPath(path string) *ViperModel
type ViperResponse ¶ added in v1.0.1
type ViperResponse struct { // 配置文件内容 Result map[string]any // 错误信息 Error error // viper实例 Viper *viper.Viper }
func (*ViperResponse) Get ¶ added in v1.0.1
func (this *ViperResponse) Get(key string, def ...any) (result any)
func (*ViperResponse) Set ¶ added in v1.0.1
func (this *ViperResponse) Set(key string, value any) (result ViperResponse)