{"id":20906031,"url":"https://github.com/telanflow/co","last_synced_at":"2025-10-15T23:28:20.402Z","repository":{"id":133912005,"uuid":"255859982","full_name":"telanflow/co","owner":"telanflow","description":"Go common libraries （Go语言公共函数库）","archived":false,"fork":false,"pushed_at":"2020-07-29T14:24:06.000Z","size":49,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-13T05:41:33.874Z","etag":null,"topics":["common","function","go","helper","library","utils"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/telanflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-15T08:57:11.000Z","updated_at":"2022-06-03T23:08:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"c2d479b9-e474-4786-b443-2c558498f4bd","html_url":"https://github.com/telanflow/co","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/telanflow/co","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telanflow%2Fco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telanflow%2Fco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telanflow%2Fco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telanflow%2Fco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telanflow","download_url":"https://codeload.github.com/telanflow/co/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telanflow%2Fco/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266235561,"owners_count":23897181,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["common","function","go","helper","library","utils"],"created_at":"2024-11-18T13:28:42.474Z","updated_at":"2025-10-15T23:28:20.326Z","avatar_url":"https://github.com/telanflow.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# co\n[![GoDoc](https://godoc.org/github.com/telanflow/co?status.svg)](https://godoc.org/github.com/telanflow/co)\n\nGo common libraries （Go语言公共库）\n\n# 函数列表\n\n### file.go\n```text\nFileExists()        文件是否存在\nFileCreateMust()    给定path创建文件，如果目录不存在就递归创建\nReaderMimeType()    获取Reader的MimeType\nFileMimeType()      获取文件的MimeType\nGetDirs()           获取目录所有文件夹\nGetFiles()          获取目录所有文件\nGetFilesSuffix()    获取指定目录及所有子目录下的所有文件，可以匹配后缀过滤\nReadLine()          按行读取文件\n```\n\n### path.go\n```text\nPathExists()        路径是否存在\nPathFillSlash()     给路径补全 `/`\nPathRemoveSlash()   移除路径最后的 `/`\nPathFormSlash()     将path中的反斜杠'\\'替换为'/'\nIsDir()             判断路径是否为目录\nIsFile()            判断路径是否为文件\n```\n\n### strings.go\n```text\nStr2Bytes()         将字符串转换为字节切片\nStr2Int()           将字符串转换为int\nStr2IntStrict()     严格将字符串转换为有符号整型\nStr2Int8()          将字符串转换为int8\nStr2Int16()         将字符串转换为int16\nStr2Int32()         将字符串转换为int32\nStr2Int64()         将字符串转换为int64\nStr2UintStrict()    严格将字符串转换为无符号整型\nStr2Uint()          将字符串转换为uint\nStr2Uint8()         将字符串转换为uint8\nStr2Uint16()        将字符串转换为uint16\nStr2Uint32()        将字符串转换为uint32\nStr2Uint64()        将字符串转换为uint64\nStr2FloatStrict()   严格将字符串转换为浮点型\nStr2Float32()       将字符串转换为float32\nStr2Float64()       将字符串转换为float64\nStr2Bool()          将字符串转换为布尔值\nRunes2Bytes()       将[]rune转为[]byte\nSplitStr()          分割字符串（该方法会过滤空字符串）\nSubStr()            字符串截取\nRepeatStr()         重复字符串\nRepeatRune()        重复字符串 rune\nPadding()           字符串填充\nPadLeft()           字符串填充 - 左侧\nPadRight()          字符串填充 - 右侧\n```\n\n### bytes.go\n```text\nBytes2Str()         将字节切片转换为字符串\nByte2Float64()      字节切片转64位浮点数\nByte2Int64()        字节切片转64位整型\nByte2Hex()          字节切片转16进制字符串\nByte2HexSlice()     字节切片转16进制切片\n```\n\n### slice.go\n```text\nContainsUint()      返回list中是否包含\nContainsInt()       返回list中是否包含\nContainsString()    返回list中是否包含\nSliceIntersect()    求两个切片交集\nSliceDifference()   求两个切片差集\n```\n\n### number.go\n```text\nInt2Str()           将整数转换为字符串\nFloat2Str()         将浮点数转换为字符串,decimal为小数位数\nBool2Str()          将布尔值转换为字符串\nBool2Int()          将布尔值转换为整型\nDec2Bin()           将十进制转换为二进制\nBin2Dec()           将二进制转换为十进制\nHex2Bin()           将十六进制字符串转换为二进制字符串\nBin2Hex()           将二进制字符串转换为十六进制字符串\nDec2Hex()           将十进制转换为十六进制\nHex2Dec()           将十六进制转换为十进制\nDec2Oct()           将十进制转换为八进制\nOct2Dec()           将八进制转换为十进制\nBaseConvert()       进制转换,在任意进制之间转换数字\nIp2Long()           将 IPV4 的字符串互联网协议转换成长整型数字\nLong2Ip()           将长整型转化为字符串形式带点的互联网标准格式地址(IPV4)\nToStr()             强制将变量转换为字符串\nToBool()            强制将变量转换为布尔值\nToInt()             强制将变量转换为整型; 其中true或\"true\"为1\nToFloat()           强制将变量转换为浮点型;其中true或\"true\"为1.0\nFloat64ToByte()     64位浮点数转字节切片\nInt64ToByte()       64位整型转字节切片\nHex2Byte()          16进制字符串转字节切片\nHexSlice2Byte()     16进制切片转byte切片\n```\n\n### map.go\n```text\nMergeStringMap()    合并给定的2个map\nKeyToLower()        将给定的map键名转换为小写\nKeys()              获取给定map的所有键名\nValues()            获取给定map的所有值\nGetByPath()         给定key获取value, 支持递归获取 （eg \"top\" \"top.sub\"）\n```\n\n### md5.go\n```text\nMd5()               获取字符串md5值, length指定结果长度32/16\nMd5Str()            字符串生成md5摘要\n```\n\n### sha1.go\n```text\nSha1Str()           计算字符串的sha1散列值\nShaXStr()           计算字符串的shaX散列值，x为1/256/512\n```\n\n### value.go\n```text\nIsEmpty()           检查变量是否为空\nIsNil()             检查变量是否空值\nIsBool()            是否布尔值\nIsHex()             是否十六进制字符串\nIsByte()            变量是否字节切片\nIsStruct()          变量是否结构体\nIsInterface()       变量是否接口\nIsString()          变量是否字符串\nIsBinary()          字符串是否二进制\n```\n\n### os.go\n```text\nIsWindows()         当前操作系统是否Windows\nIsLinux()           当前操作系统是否Linux\nIsDarwin()          当前操作系统是否Mac OS/X\nIsMSys()            msys(MINGW64) env，不一定支持颜色\nIsConsole()         check out is in stderr/stdout/stdin\nGetCwd()            获取当前执行文件的真实目录（不受 os.Chdir 函数影响） \n```\n\n### exec.go\n```text\nQuickExec()         快速执行cli命令\nExecCmd()           执行命令并返回输出\nShellExec()         通过shell执行exec命令\n```\n\n### random.go\n```text\nRandInt()                   随机获取 min - max 之间的数值\nRandInt64()                 随机获取 min - max 之间的数值\nRandIntSlice()              随机获取 min - max 之间的数值切片\nRandInt64Slice()            随机获取 min - max 之间的数值切片\nRandStr()                   生成随机字符串\nRandBytes()                 生成随机字节切片\nRandStrForBytes()           生成随机字符串\nRandStrToLower()            字符串随机字符转小写\nRandStrToUpper()            字符串随机字符转大写\nRandStrToUpperWithIndex()   指定字符索引转大写\nRandStrToUpperWithIndex()   指定字符索引转小写\n```\n\n### mist.go [薄雾算法](https://github.com/asyncins/mist)\n```text\nMistGenerate()      生成全局唯一ID\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelanflow%2Fco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelanflow%2Fco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelanflow%2Fco/lists"}