Documentation ¶
Index ¶
- func AuthCode(str string, operation string, key string, expiry int64) string
- func Base64Decode(base64Str string) (content string)
- func BasicTypeReflectSetValue(rv reflect.Value, value string) (err error)
- func BigToLittleEndian[T int | uint64 | uint32 | uint16](bigEndian T) (result T)
- func BoolToInt(value bool) int
- func BoolToStrNumber(value bool) string
- func Date(t time.Time, format string) string
- func DefaultValue(data interface{}) (err error)
- func DeleteByIndex(slice interface{}, index int) (err error)
- func DeleteByValue(slice interface{}, value interface{}) (err error)
- func EnvOrDefault(envName string, defaultValue string) string
- func ErrorCaller(err error) error
- func EscapeWindowsFilename(filename string) string
- func FileExists(filePath string) bool
- func FileGetContents(filename string) (content string)
- func GbkToUtf8(s []byte) ([]byte, error)
- func IP2Long(ip string) (*big.Int, int64, error)
- func InSlice(slice interface{}, value interface{}) (exists bool, err error)
- func IsBigEndianCPU() bool
- func IsEmptyDir(dirPath string) bool
- func LittleToBigEndian[T int | uint64 | uint32 | uint16](littleEndian T) (result T)
- func LogJSON(value interface{})
- func Long2IP(ip *big.Int, ipv4 int64) string
- func Md5(s string) string
- func PHPDate(stamp int64, format string) string
- func PackInt[T int32 | int16 | int8 | uint32 | uint16 | uint8](hightBitNumber T, lowBitNumnber T) (packedNumber uint64)
- func ParseStructWithEnv(structNode interface{}, rootNodeName string)
- func ReadDirRecusive(path string, callback func(filePath string) (err error)) (err error)
- func RegisterSignalCallback(callback func(), signals ...os.Signal)
- func SlicePager(input interface{}, outut interface{}, p *SlicePagerOpts) (err error)
- func StrToEnvName(s string) (ret string)
- func StringDefault(source *string, defaultValue string)
- func StripHtmlTags(html string) (s string)
- func SubStr(str string, begin, length int) (substr string)
- func Utf8ToGbk(s []byte) ([]byte, error)
- type DockerImageNameInfo
- type SlicePagerOpts
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthCode ¶
AuthCode Comsenz discuz classical symmetric encryption/decryption function, example see authcode_test.go#TestAuthCode() AuthCode 康盛Discuz! 经典对称加解密函数,用法参考 authcode_test.go#TestAuthCode()
func Base64Decode ¶
Base64Decode base64解码 http://php.net/manual/en/function.base64-decode.php
func BasicTypeReflectSetValue ¶
BasicTypeReflectSetValue use reflect.Value set value, main used for function DefaultValue(), usage see struct_test.go#TestBasicTypeReflectSetValue(),current not support pointer types, BasicTypeReflectSetValue 使用reflect.Value来修改变量的值,主要用于函数DefaultValue(),使用示范见struct_test.go#TestDefaultValue(),当前不支持指针类型变量
func BigToLittleEndian ¶
func BoolToStrNumber ¶
func DefaultValue ¶
func DefaultValue(data interface{}) (err error)
DefaultValue simply set default value to struct field by "default" tag current support struct field types [ float32 float64 uint int uint8 int8 uint16 int16 uint32 int32 uint64 int64 bool string slice array map ],current not support pointer types, not support unexported field(lower case named field), usage example see struct_test.go#TestDefaultValue() DefaultValue 简单的设置默认值给结构体字段,通过default标签 当前支持的结构体字段类型 [ float32 float64 uint int uint8 int8 uint16 int16 uint32 int32 uint64 int64 bool string slice array map ],当前不支持指针类型变量,不支持未导出的结构体字段(名字小写的字段) 使用示范见struct_test.go#TestDefaultValue()
func DeleteByIndex ¶
DeleteByIndex delete slice element from slice by index Dont use this function on big slice Example see slice_test.go#TestDeleteByIndex() DeleteByIndex 以指定的索引下标删除slice中的某个元素,请勿用于巨大的slice
func DeleteByValue ¶
func DeleteByValue(slice interface{}, value interface{}) (err error)
DeleteByValue delete slice element from slice by value if value matched multiple elements, theese elements will be delete from slice Dont use this function on big slice Example see slice_test.go#TestDeleteByValue() DeleteByValue 以指定的值标删除slice中的N个元素,请勿用于巨大的slice
func EnvOrDefault ¶
EnvOrDefault read OS environment variable name, if value is "", then return defaultValue EnvOrDefault 读取环境变量名的值,如果为空则返回第二个参数的值,否则直接返回换将变量名对应的值
func ErrorCaller ¶
ErrorCaller insert caller to error info, inlucde package name and function name ErrorCaller 将调用处的包名和函数追加到error信息中
func EscapeWindowsFilename ¶
EscapeWindowsFilename escape special character for windows name EscapeWindowsFilename 转义windows文件名特殊字符
func FileExists ¶
FileExists check file exists FileExists 查询一个文件是否存在
func FileGetContents ¶
FileGetContents read file into a string variable FileGetContents 把一个文件读成一个字符串 http://php.net/manual/en/function.file-get-contents.php
func IP2Long ¶
IP2Long ip字符串转换为整数 IP2Long ip string to number from https://blog.csdn.net/janbar/article/details/127709072
func InSlice ¶
InSlice check if element exists in a slice value type and slice element type must be same Dont use this function on big slice Example see slice_test.go#TestInSlice() InSlice 检测值是否存在于slice中
func IsBigEndianCPU ¶
func IsBigEndianCPU() bool
IsBigEndianCPU 检测主机内存字节序,一般来说power PC 这些IBM的CPU是大端序内存布局,而intel的CPU则是小端序布局。只有超过2个字节的数据类型才会有端序的概念,因此这里不检查uint8
func IsEmptyDir ¶
IsEmptyDir check path if is a empty directory IsEmptyDir 查询一个目录是否是空目录
func LittleToBigEndian ¶
func Long2IP ¶
Long2IP ip整数转换为字符串 Long2IP ip number to string from https://blog.csdn.net/janbar/article/details/127709072
func ParseStructWithEnv ¶
func ParseStructWithEnv(structNode interface{}, rootNodeName string)
func ReadDirRecusive ¶
ReadDirRecusive read files under directory with recursive ReadDirRecusive 递归读取目录下所有的文件和文件夹
func RegisterSignalCallback ¶
RegisterSignalCallback watch system signal and do callback function , this function will stuck current goroutine before received signal RegisterSignalCallback 监听系统系统并执行回调,如果没有收到信号则卡住当前goroutine
func SlicePager ¶
func SlicePager(input interface{}, outut interface{}, p *SlicePagerOpts) (err error)
SlicePager paginate slice by SlicePagerOpts SlicePager 基于slice做分页
func StrToEnvName ¶
StrToEnvName cover string to linux style environment variable name, only [A-Za-z\-_\.] will be convert to underscore StrToEnvName 将字符串转换为linux环境变量名称 只收录字符 [A-Za-z\-_\.] 点号会被转转为下划线
func StringDefault ¶
StringDefault if string variable value is empty, give it default value StringDefault 如果字符串值为空,则给予默认值
func StripHtmlTags ¶
StripHtmlTags remove html tags and return text content only StripHtmlTags 去除html标签并返回纯文本内容
Types ¶
type DockerImageNameInfo ¶
type DockerImageNameInfo struct { // Schema api server http schema, values are http or https // Schema 仓库服务器访问方式,http或https Schema string `json:"schema"` // Domain api server host domain // Domain 仓库服务器域名 Domain string `json:"domain"` // Path image base name, such as rumia/rds-operator or pizza/rumia/rds-operator or library/centos // Path 镜像基本名称,比如 rumia/rds-operator or pizza/rumia/rds-operator or library/centos Path string `json:"path"` // Tag image tag, exclusive with Digest column // Tag 镜像tag,和sha256签名互斥 Tag string `json:"tag"` // Digest image sha256 digest, exclusive with Tag column // Digest 镜像sha256签名,和tag字段互斥 Digest string `json:"digest"` }
DockerImageNameInfo docker image information DockerImageNameInfo docker image 信息
func ParseDockerImageNameInfo ¶
func ParseDockerImageNameInfo(imageName string) (info *DockerImageNameInfo)
ParseDockerImageNameInfo parse docker image info by image name ParseDockerImageNameInfo 通过镜像名称解析docker镜像信息
func (*DockerImageNameInfo) GetReference ¶
func (t *DockerImageNameInfo) GetReference() (tagOrDigest string)
GetReference return sha256 digest or tag name , always used for docker registry v2 client GetReference 返回sha256签名或tag名称 , 通常用于 docker registry v2 客户端
func (*DockerImageNameInfo) String ¶
func (t *DockerImageNameInfo) String() (fullname string)
String format output String 格式化输出
type SlicePagerOpts ¶
type SlicePagerOpts struct { // CurrentPage current page // CurrentPage 当前页 CurrentPage int `json:"currentPage"` // TotalPages total pages // TotalPages 总页数 TotalPages int `json:"totalPages"` // TotalNum total elements count of slice // TotalNum 总共有多少条数据在slice TotalNum int `json:"totalNum"` // Limit how many slice elements per page // Limit 每页将有多少条数据 Limit int `json:"limit"` }
SlicePagerOpts pagination settings SlicePagerOpts 分页设置
type Version ¶
type Version struct { // Major major verion is always with some breaking changes // Major 主版本通常是带有不可逆的功能变更 Major int // Minor minor version is always with some compatible function changes in major version // Minor 次要版本通常不会发生不可逆功能变更,主要是新增一些功能 Minor int // Bugfix bugfix version is always with some bug fix, no any breaking change or function change // Bugfix bug修复版本通常只是修复bug,不会发生功能新增或更改 Bugfix string }
func ParseVersion ¶
ParseVersion support version styles are v0.0.0 and 0.0.0 ParseVersion 解析版本号字符串