Categorygithub.com/webx-top/com
modulepackage
1.3.25
Repository: https://github.com/webx-top/com.git
Documentation: pkg.go.dev

# README

Common functions

This is an open source project for commonly used functions for the Go programming language.

This package need >= go 1.2

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AbsURL 获取页面内相对网址的绝对路径.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
AppendStr appends string to slice with no duplicates.
Argon2CheckPassword compares an argon2 hash against plaintext password.
Argon2MakePassword takes a plaintext password and generates an argon2 hash.
Argon2MakePasswordShortly takes a plaintext password and generates an argon2 hash.
No description provided by the author
No description provided by the author
Base64Decode base64 decode.
Base64Encode base64 encode.
No description provided by the author
BCryptCheckPassword 检查密码.
BCryptMakePassword 创建密码(生成60个字符).
No description provided by the author
Br2nl change <br/> to \n.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
CallFunc 根据名称调用对应函数.
CamelCase : webx_top => webxTop.
No description provided by the author
CheckPassword 检查密码(密码原文,数据库中保存的哈希过后的密码,数据库中保存的盐值).
No description provided by the author
CleanMoreNl remove all \n(2+).
CleanMoreSpace remove all spaces(2+).
No description provided by the author
No description provided by the author
ClearHTMLAttr clear all attributes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
CompareSliceStr compares two 'string' type slices.
CompareSliceStrU compares two 'string' type slices.
No description provided by the author
ConvDateFormat Convert PHP time format.
ConvertNumberArToCh 阿拉伯数字转中文数字.
ConvertNumberArToChUpper 阿拉伯数字转大写中文数字.
ConvertNumberChToAr 中文数字转阿拉伯数字.
Copy copies file from source to target path.
CopyDir copy files recursively from source to target directory.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
CreateFile create file.
Date Format unix time int64 to string.
DateFormat 将时间戳格式化为日期字符窜.
DateFormatShort 格式化耗时.
DateParse Parse Date use PHP time format.
DateS Format unix time string to string.
DateT Format time.Time struct to string MM - month - 01 M - month - 1, single bit DD - day - 02 D - day 2 YYYY - year - 2006 YY - year - 06 HH - 24 hours - 03 H - 24 hours - 3 hh - 12 hours - 03 h - 12 hours - 3 mm - minute - 04 m - minute - 4 ss - second - 05 s - second = 5.
No description provided by the author
No description provided by the author
Dump 输出对象和数组的结构信息.
ElapsedMemory 内存占用.
No description provided by the author
ExecCmd executes system command and return stdout, stderr in string type, along with possible error.
ExecCmdBytes executes system command and return stdout, stderr in bytes type, along with possible error.
ExecCmdBytesWithContext executes system command and return stdout, stderr in bytes type, along with possible error.
ExecCmdDir executes system command in given directory and return stdout, stderr in string type, along with possible error.
ExecCmdDirBytes executes system command in given directory and return stdout, stderr in bytes type, along with possible error.
ExecCmdDirBytesWithContext executes system command in given directory and return stdout, stderr in bytes type, along with possible error.
ExecCmdDirWithContext executes system command in given directory and return stdout, stderr in string type, along with possible error.
ExecCmdWithContext executes system command and return stdout, stderr in string type, along with possible error.
ExitOnFailure 失败时退出程序.
ExitOnSuccess 成功时退出程序.
Expand replaces {k} in template with match[k] or subs[atoi(k)] if k is not in match.
No description provided by the author
FetchFiles fetches files specified by the rawURL field in parallel.
FetchFilesCurl uses command `curl` to fetch files specified by the rawURL field in parallel.
FileExists reports whether the named file or directory exists.
FileIsCompleted 等待文件有数据且已写完 费时操作 放在子线程中执行 @param file 文件 @param start 需要传入 time.Now.Local(),用于兼容遍历的情况 @return true:已写完 false:外部程序阻塞或者文件不存在 翻译自:https://blog.csdn.net/northernice/article/details/115986671.
FileMTime returns file modified time and possible error.
FileSize returns file size in bytes and possible error.
FindChineseWords find chinese words.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
FormatByte 兼容以前的版本,FormatBytes别名 @param float64 size @param int precision @param bool trimRightZero.
FormatBytes 格式化字节。 FormatBytes(字节整数,保留小数位数, 是否裁剪掉小数中的后缀0) 不设置 参数 2 和 参数 3 时,默认保留2为小数并裁剪小数中的后缀0 @param float64 size @param int precision @param bool trimRightZero.
FormatPastTime 格式化耗时 @param number timestamp @param string args[0] 时间格式 @param string args[1] 已过去时间后缀 @param string args[2] 语种.
FriendlyTime 对人类友好的经历时间格式 @param time.Duration d @param string suffix @param int precision @param bool trimRightZero @param string language.
No description provided by the author
FuncFullPath 返回完整路径包名、实例名和函数名.
FuncName 函数名.
FuncPath 返回包名、实例名和函数名.
GetAllSubDirs returns all subdirectories of given root path.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetGOPATHs returns all paths in GOPATH variable.
GetJSON Read json data, writes in struct f.
GetMatchedByIndex 通过 FindAllStringSubmatchIndex 的值获取匹配结果 matches = FindAllStringSubmatchIndex for _, match := range matches { var fullmatch string GetMatchedByIndex(contet, match, &fullmatch) }.
No description provided by the author
GetSrcPath returns app.
No description provided by the author
No description provided by the author
No description provided by the author
GonicCase : webxTop => webx_top.
GrepFile like command grep -E for example: GrepFile(`^hello`, "hello.txt") \n is striped while read.
HasChinese contains Chinese.
No description provided by the author
Hash 生成哈希值.
No description provided by the author
No description provided by the author
HasTableAlias 检查sql语句中是否包含指定表别名sqlStr 可以由"<where子句>,<select子句>,<orderBy子句>,<groupBy子句>"组成.
HomeDir returns path of '~'(in Linux) on Windows, it returns error when the variable does not exist.
HTML2JS converts []byte type of HTML content into JS format.
HTMLDecode decode string to html chars.
HTMLDecodeAll decode string to html chars.
HTMLEncode encode html chars to string.
No description provided by the author
No description provided by the author
HTTPGet gets the specified resource.
HTTPGetBytes gets the specified resource.
HTTPGetJSON gets the specified resource and mapping to struct.
HTTPGetToFile gets the specified resource and writes to file.
HTTPPost ==============================.
No description provided by the author
No description provided by the author
HumaneFileSize calculates the file size and generate user-friendly string.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
IsAlphaNumericUnderscore 是否仅仅包含字母、数字、和下划线.
IsAlphaNumericUnderscoreHyphen 是否仅仅包含字母、数字、下划线和连字符(-).
No description provided by the author
IsChinese validate string is Chinese.
IsDir returns true if given path is a directory, or returns false when it's a file or does not exist.
IsEmail validate string is an email address, if not return false basically validation can match 99% cases.
IsEmailRFC validate string is an email address, if not return false this validation omits RFC 2822.
IsExist checks whether a file or directory exists.
IsFile returns true if given path is a file, or returns false when it's a directory or does not exist.
IsFloat validate string is a float number.
No description provided by the author
IsInteger validate string is a integer.
IsLetter returns true if the 'l' is an English letter.
IsLocalhost 是否是本地主机.
IsMultiLineText validate string is a multi-line text.
IsNetworkOrHostDown - if there was a network error or if the host is down.
No description provided by the author
IsSingleLineText validate string is a single-line text.
IsSliceContainsInt64 returns true if the int64 exists in given slice.
IsSliceContainsStr returns true if the string exists in given slice.
IsUnsignedInteger validate string is a unsigned-integer.
No description provided by the author
IsURL validate string is a url link, if not return false simple validation can match 99% cases.
IsUsername validate string is a available username.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
LeftPadZero 字符串指定长度,长度不足的时候左边补零.
No description provided by the author
No description provided by the author
No description provided by the author
LowerCaseFirst : WEBX => wEBX.
Ltrim trim space on left.
MakePassword 创建密码(生成64个字符) 可以指定positions用来在hash处理后的密码的不同位置插入salt片段(数量取决于positions的数量),然后再次hash.
No description provided by the author
MarshalStream .
MaskString 0123456789 => 012****789.
MBToSBText 全角转半角.
Md5 md5 hash string.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Monitor 文件监测.
No description provided by the author
No description provided by the author
No description provided by the author
NewCookie is a helper method that returns a new http.Cookie object.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Nl2br change \n to <br/>.
Notify 等待系统信号 <-Notify().
NowStr 当前时间字符串.
No description provided by the author
No description provided by the author
No description provided by the author
Offset 根据页码计算偏移值.
No description provided by the author
No description provided by the author
ParseDuration creates a new *Durafmt struct, returns error if input is invalid.
ParseDurationString creates a new *Durafmt struct from a string.
No description provided by the author
No description provided by the author
ParseFuncName 解析函数名.
No description provided by the author
No description provided by the author
No description provided by the author
PascalCase : webx_top => WebxTop.
No description provided by the author
PBKDF2Key derives a key from the password, salt and iteration count, returning a []byte of length keylen that can be used as cryptographic key.
PowInt is int type of math.Pow function.
RandFloat32 获取范围为[0.0, 1.0],类型为float32的随机小数.
RandFloat64 获取范围为[0.0, 1.0],类型为float64的随机小数.
RandInt Get in the range [0, max], a random integer type int.
RandomAlphabetic Creates a random string whose length is the number of characters specified.
RandomAlphanumeric Creates a random string whose length is the number of characters specified.
RandomASCII Creates a random string whose length is the number of characters specified.
RandomCreateBytes generate random []byte by specify chars.
RandomNumeric Creates a random string whose length is the number of characters specified.
No description provided by the author
No description provided by the author
No description provided by the author
RandPerm 获取范围为[0,max],数量为max,类型为int的随机整数slice.
RandRangeInt 生成区间随机数 @param int min 最小值 @param int max 最大值 @return int 生成的随机数.
RandRangeInt64 生成区间随机数 @param int64 min 最小值 @param int64 max 最大值 @return int64 生成的随机数.
No description provided by the author
RandStr .
No description provided by the author
RawURLDecode rawurldecode().
RawURLEncode rawurlencode().
No description provided by the author
ReadFile reads data type '[]byte' from file by given path.
ReadFileS reads data type 'string' from file by given path.
ReadJSON Json data read from the specified file.
No description provided by the author
No description provided by the author
No description provided by the author
RemoveEOL remove \r and \n.
RemoveXSS 删除XSS代码.
GoLang: os.Rename() give error "invalid cross-device link" for Docker container with Volumes.
ReplaceByMatchedIndex 通过 FindAllStringSubmatchIndex 的值来替换 matches = FindAllStringSubmatchIndex var replaced string replacer := ReplaceByMatchedIndex(content, matches, &replaced) for k, v := range matches { var fullmatch string replacer(k, v, `newContent`) }.
RestoreTime 从字符串还原时间 RestoreTime(`2001-01-01T00:00:03Z`).Format(`2006-01-02 15:04:05`) => 2001-01-01 00:00:03.
Reverse s string, support unicode.
No description provided by the author
Round 保留几位小数(四舍五入).
Rtrim trim space on right.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SafeBase64Decode base64 decode.
SafeBase64Encode base64 encode.
Salt 盐值加密(生成64个字符).
SaveFile saves content type '[]byte' to file by given path.
SaveFileS saves content type 'string' to file by given path.
SBToMBText 半角转全角.
SearchFile search a file in paths.
No description provided by the author
No description provided by the author
SeekRangeNumbers 遍历范围数值,支持设置步进值。格式例如:1-2,2-3:2.
No description provided by the author
No description provided by the author
No description provided by the author
SetJSON Struct s will be converted to json format.
Sha1 sha1 hash string.
Sha256 sha256 hash string.
Shuffle 打乱数组.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SliceRemove SliceRomove(a,4,5) //a[4].
SliceRemoveCallback : 根据条件删除 a=[]int{1,2,3,4,5,6} SliceRemoveCallback(len(a), func(i int) func(bool)error{ if a[i]!=4 { return nil } return func(inside bool)error{ if inside { a=append(a[0:i],a[i+1:]...) }else{ a=a[0:i] } return nil } }).
No description provided by the author
No description provided by the author
No description provided by the author
SnakeCase : WebxTop => webx_top.
No description provided by the author
No description provided by the author
SplitHost localhost:8080 => localhost.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
StatDir gathers information of given directory by depth-first.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
StripTags strip tags in html string.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
StrRepeat repeat string times.
StrReplace replace find all occurs to string.
No description provided by the author
StrToTime 日期字符窜转为时间戳数字.
Substr returns the substr from start to length.
TarGz 压缩为tar.gz args: regexpFileName, regexpIgnoreFile.
No description provided by the author
TestReflect 测试反射:显示字段和方法信息.
TextLine Single line of text.
No description provided by the author
TitleCase : webx_top => Webx_Top.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ToStr Convert any type to string.
TotalPages 总页数.
TotalRunTime 总运行时长.
No description provided by the author
Trim trim space in all string length.
TrimFileName trim the file name.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
UnmarshalStream .
UnTarGz ungzips and untars .tar.gz file to 'destPath' and returns sub-directories.
Unzip unzips .zip file to 'destPath'.
UpperCaseFirst : webx => Webx.
UpperChNumber 大写中文数字.
URLDecode url decode string.
URLEncode url encode string, is + not %20.
URLSafeBase64 base64字符串编码为URL友好的字符串.
No description provided by the author
VersionCompare compare two versions in x.y.z form @param {string} a version string @param {string} b version string @return {int} 1 = a is higher, 0 = equal, -1 = b is higher.
VersionComparex compare two versions in x.y.z form @param {string} a version string @param {string} b version string @param {string} op <,<=,>,>=,= or lt,le,elt,gt,ge,egt,eq @return {bool}.
WatchingStdin Watching os.Stdin example: go WatchingStdin(ctx,`name`,fn).
No description provided by the author
No description provided by the author
No description provided by the author
WriteFile writes data to a file named by filename.
WriteJSON The json data is written to the specified file.
WritePidFile writes the process ID to the file at PidFile.
Zip 压缩为zip args: regexpFileName, regexpIgnoreFile.

# Constants

Storage unit constants.
No description provided by the author
Storage unit constants.
Storage unit constants.
0.5秒.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Storage unit constants.
No description provided by the author
Storage unit constants.
Storage unit constants.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Storage unit constants.
VersionCompareEq 左等于右.
VersionCompareGt 左大于右.
VersionCompareLt 左小于右.

# Variables

No description provided by the author
No description provided by the author
DateFormatReplacer .
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ErrIncompatibleVariant is returned by ComparePasswordAndHash if the provided hash was created using a unsupported variant of Argon2.
ErrIncompatibleVersion is returned by ComparePasswordAndHash if the provided hash was created using a different version of Argon2.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
StartTime 开始时间.
TimeShortUnits 时间单位(简写).
TimeUnits 多语言时间单位.
No description provided by the author

# Structs

Params describes the input parameters used by the Argon2id algorithm.
No description provided by the author
No description provided by the author
No description provided by the author
Durafmt holds the parsed duration and the original input duration.
MonitorEvent 监控事件函数.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
A RawFile describes a file that can be downloaded.
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author