# README
crab
# Functions
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
And returns true if both a and b are truthy.
验证密钥.
生成密钥.
生成密钥带类型.
生成密钥带类型和设置.
ArrayToString 数字切片变字符串.
Base64StdDecode decode a base64 encoded string.
Base64StdEncode encode string with base64 encoding.
Bool returns the truthy value of anything.
No description provided by the author
aeadEncrypt encrypts a message with a one-time key.
ClearFile write empty string to path file.
ColorHexToRGB convert hex color to rgb color.
ColorRGBToHex convert rgb color to hex color.
CompareOsEnv gets env named by the key and compare it with comparedEnv.
ContainChinese check if the string contain mandarin chinese.
ContainLetter check if the string contain at least one letter.
ContainLower check if the string contain at least one lower case letter a-z.
ContainNumber check if the string contain at least one number.
ContainSubSlice check if the slice contain a given subslice or not.
ContainUpper check if the string contain at least one upper case letter A-Z.
CopyFile copy src file to dest file.
CreateDir create directory in absolute path.
CreateFile create a file in path.
CurrentPath return current absolute path.
CurrentShell get current used shell env file.
No description provided by the author
Equal checks if two slices are equal: the same length and all elements' order and value are equal.
ExecCmd an command and return output.
FileAppend 追加内容到文件中.
Suffix get filename ext.
FileLoopDirs 遍历目录下的所有子目录,即返回pathname下面的所有目录,目录为绝对路径.
FileLoopFileNames 遍历文件夹及子文件夹下的所有文件名,即返回pathname目录下所有的文件,文件名为相对路径.
FileLoopFiles 遍历文件夹及子文件夹下的所有文件,即返回pathname目录下所有的文件,文件名为绝对路径.
FileLoopOneDirs 遍历目录下的所有子目录,即返回pathname下面的所有目录,目录为相对路径.
FileMode return file's mode and permission.
FileMove 移动文件.
FileParentPath 文件父路径.
FilePathExists 判断路径是否存在.
FileReadPointLine 从文件中读取指定行并返回字符串数组.
FilterPrefix 根据前缀过滤slice.
FindCommandPath 获取命令的路径.
FindLongestStr 查询最长字符串.
FindUser find an system user by name.
GenerateKey aes bit: 16/24/32 chacha: 32.
GenerateRSAKey 创建RSA 常用位数 1024 2048 4096.
GenerateRSAKeyWithPwd 创建带密码的RSA.
CurrentUser get current user.
GetFilepaths get all filepaths in a directory tree.
GetLoginUser get current user, alias of CurrentUser.
GetOsBits return current os bits (32 or 64).
GetOsEnv gets the value of the environment variable named by the key.
获取项目路径.
HmacMd5 return the hmac hash of string use md5.
HmacSha1 return the hmac hash of string use sha1.
HmacSha256 return the hmac hash of string use sha256.
HmacSha512 return the hmac hash of string use sha512.
HomeDir get user home dir path, alias .
Hostname is alias of os.Hostname, but ignore error.
IsAbsPath is abs path.
IsAllLower check if the string is all lower case letters a-z.
IsAllUpper check if the string is all upper case letters A-Z.
IsAlpha checks if the string contains only letters (a-zA-Z).
IsAMD64 check if current arch is amd64 or x86_64.
IsAmericanExpress check if a give string is a valid american expression card nubmer or not.
IsARM64 check if current arch is arm64 or aarch.
IsASCII checks if string is all ASCII char.
IsBase64 check if the string is base64 string.
IsBase64URL check if a give string is a valid URL-safe Base64 encoded string.
IsBin check if a give string is a valid binary value or not.
IsChinaUnionPay check if a give string is a valid china union pay nubmer or not.
IsChineseIdNum check if the string is chinese id card.
IsChineseMobile check if the string is chinese mobile number.
IsChinesePhone check if the string is chinese phone number.
IsCreditCard check if the string is credit card.
IsDir checks if the path is directory or not.
IsDns check if the string is dns.
IsEmail check if the string is a email address.
IsEmptyString check if the string is empty.
IsExist checks if a file or directory exists.
IsFile reports whether the named file or directory exists.
IsFloat check if the value is float(float32, float34) or not.
IsFloatStr check if the string can convert to a float.
IsGBK check if data encoding is gbk Note: this function is implemented by whether double bytes fall within the encoding range of gbk, while each byte of utf-8 encoding format falls within the encoding range of gbk.
IsHex check if a give string is a valid hexadecimal value or not.
IsInt check if the value is integer(int, unit) or not.
IsIntStr check if the string can convert to a integer.
IsIp check if the string is a ip address.
IsIpV4 check if the string is a ipv4 address.
IsIpV6 check if the string is a ipv6 address.
IsJSON checks if the string is valid JSON.
IsJWT check if a give string is a valid JSON Web Token (JWT).
IsLink checks if a file is symbol link or not.
IsLinux check if current os is linux.
IsMac check if current os is macos.
IsMasterCard check if a give string is a valid master card nubmer or not.
IsNumber check if the value is number(integer, float) or not.
IsNumberStr check if the string can convert to a number.
IsPort check if the string is a valid net port.
IsPrintable checks if string is all printable chars.
IsPublicIPv4 ipv4 判断是否是公网ip.
IsRegexMatch check if the string match the regexp.
IsStrongPassword check if the string is strong password, if len(password) is less than the length param, return false Strong password: alpha(lower+upper) + number + special chars(!@#$%^&*()?><).
IsUnionPay check if a give string is a valid union pay nubmer or not.
IsUrl check if the string is url.
IsVisa check if a give string is a valid visa card nubmer or not.
IsWeakPassword check if the string is weak password Weak password: only letter or only number or letter + number.
IsWindows check if current os is windows.
IsZeroValue checks if value is a zero value.
IsZipFile checks if file is zip or not.
LenToSubNetMask ipv4 网络位长度转换为子网掩码地址 如 24 对应的子网掩码地址为 255.255.255.0.
ListFileNames return all file names in the path.
Md5File return the md5 value of file.
Md5String return the md5 value of string.
MiMeType return file mime type param `file` should be string(file path) or *os.File.
MkDir 创建文件夹,支持x/a/a 多层级.
Name get file/dir name 获取路径的文件名.
Nand returns false if both a and b are truthy.
Nor returns true if neither a nor b is truthy.
Or returns false if neither a nor b is truthy.
Dir get dir path, without last name.
Prefix 获取文件名前缀, /tmp/main.go 获取的文件前缀是main.
ReadCsvFile read file content into slice.
ReadFile 读文件.
ReadFileByLine read file line by line.
ReadFileToString return string of file content.
RecreateDir recreate dir.
RemoveFile remove the path file.
RemoveOsEnv remove a single environment variable.
RSADecryptOAEP 私钥解密.
RSADecryptOAEPPwd 私钥解密,带密码.
RSAEncryptOAEP 公钥加密.
RunCmd 获取标准正确输出.
RunCMD 标准正确错误输出到标准正确输出.
RunCommandWithTimeout 带超时控制的执行shell命令.
SetOsEnv sets the value of the environment variable named by the key.
Sha1 return the sha1 value (SHA-1 hash algorithm) of string.
Sha1File return the sha1 value of file.
Sha256 return the sha256 value (SHA256 hash algorithm) of string.
Sha256File return the sha256 value of file.
Sha512 return the sha512 value (SHA512 hash algorithm) of string.
Sha512File return the sha512 value of file.
Combine is used to reverse a Split and reconstruct a secret once a `threshold` number of parts are available.
Split takes an arbitrarily long secret and generates a `parts` number of shares, `threshold` of which are required to reconstruct the secret.
Chunk creates a slice of elements split into groups the length of size.
Merge all given slices into one slice.
Union creates a slice of unique elements, in order, from all given slices.
Unique remove duplicate elements in slice.
UpdateAt update the slice element at index.
StringBuild 拼接字符串.
StringBuildSep 拼接字符串.
StringAllLetter 判断字符串是否只由字母组成.
StringTrim 去除字符串中的空格和换行符.
StringTrimN 去除字符串中的换行符.
SubNetMaskToLen ipv4 子网掩码长度换算 如 255.255.255.0 对应的网络位长度为 24.
SubString 截取字符串.
Suffix get filename ext.
TarGzip 压缩 使用gzip压缩成tar.gz.
TernaryOperator checks the value of param `isTrue`, if true return ifValue else return elseValue.
ToBool convert string to boolean.
ToBytes convert value to byte slice.
ToChannel convert a slice of elements to a read-only channel.
ToChar convert string to char slice.
ToFloat convert value to float64, if input is not a float return 0.0 and error.
ToInt convert value to int64 value, if input is not numerical, return 0 and error.
ToJson convert value to a json string.
ToPointer returns a pointer to passed value.
ToSlice returns a slices of a variable parameter transformation.
ToString convert value to string for number, string, []byte, will convert to string for other type (slice, map, array, struct) will call json.Marshal.
UnTarGzip 解压 tar.gz.
UnZip unzip the file and save it to destPath.
UserCacheDir will prepend user `$HOME/.cache` to subPath.
UserConfigDir will prepend user `$HOME/.config` to subPath.
UserDir will prepend user home dir to subPath.
UserHomeDir get user home dir path.
Where 获取命令的路径,FindCommandPath的别名.
Workdir get.
WriteCsvFile write content to target csv file.
WriteFile 写文件.
WriteMapsToCsv write slice of map to csv file.
WriteStringToFile write string to file.
Xnor returns true if both a and b or neither a nor b are truthy.
Xor returns true if a or b but not both is truthy.
Zip create zip file, fpath could be a single file or a directory.
# Constants
ShareOverhead is the byte size overhead of each share when using Split on a secret.