Documentation ¶
Index ¶
- func Base64StdEncodingDecode(input string) ([]byte, error)
- func Base64StdEncodingEncodeToString(input []byte) string
- func BetweenStr(str, start, end string) string
- func CheckPingBaseURL(baseURL string) (retBool bool)
- func ClearUrl(text string) string
- func CreateUUID() (string, error)
- func CrosscheckKey(key string, maxKey int) (retBool bool)
- func CrosscheckKeyWithBase(keyBase, key string, maxKey int) (retBool bool)
- func EncryptHmacSha256(data string, secret string) string
- func EncryptHmacmd5(src, key string) (cryptext string)
- func EncryptMd5(source string) (cryptext string)
- func EncryptMd5Byte(source []byte) (cryptext string)
- func EncryptSha1(plaintext string) (cryptext string)
- func FileExist(path string) bool
- func GB18030String(str string) string
- func Gb18030ToUtf8(s []byte) ([]byte, error)
- func Gb18030ToUtf8String(s string) string
- func GetAbsPath(tmpName, defaultName string) string
- func GetBetweenStr(str, start, end string) string
- func GetRedirectUrl(str string, isClear bool) (string, error)
- func GetRedirectUrlEx(str string, isClear bool) (retText string, err error)
- func GetRedirectUrlJD(str string, isClear bool) (retText string, err error)
- func GetRedirectUrlWithTCN(str string, isClear bool) (retText string, err error)
- func GetRel(basepath, targpath string) string
- func GetSafeHtml(text string) (string, error)
- func GetTextCleaner(textStr string) (retText, retHash string)
- func GetUrlToByte(url string) (retByte []byte, err error)
- func GetUrlToByteEx(url string, timeOut time.Duration) (retByte []byte, err error)
- func GetUrlToString(url string) (retText string, err error)
- func GetUrlToStringEx(url string, timeOut time.Duration) (retText string, err error)
- func GetUrlWithCookieToString(url, cookie, host, referer, userAgent string) (retText string, err error)
- func GetUrlWithCookieToStringAndSaveFile(url, cookie, host, referer, userAgent, filePath string) (retText string, err error)
- func Getwd() string
- func Gzip(data []byte)
- func IsExist(f string) bool
- func IsExists(path string) (bool, error)
- func IsFile(f string) bool
- func IsFileExist(path string) (bool, error)
- func JsonDecode(data string, inter interface{}) error
- func JsonDecodeByte(bytes []byte) map[string]interface{}
- func JsonDecodeString(String string) map[string]interface{}
- func JsonEncode(data interface{}) string
- func JsonEncodeMapToByte(stringMap map[string]interface{}) []byte
- func KeyworldListParse(keyworldListStr string) []string
- func KeyworldListParseToArrMap(keyworldText string) []map[string]string
- func KeyworldListParseToMap(keyworldText string) map[string]string
- func LeftStr(str, posStr string, isContainsPosStr bool) string
- func MD5Hash(text string) string
- func Marshal(obj interface{}) string
- func MarshalEx(obj interface{}, isEscapeHTML bool) string
- func MkDir(path string) error
- func MsgSignatureCheck(msgmsgSignature string, maxKey int) (retBool bool)
- func MsgSignatureCheckEx(msgmsgSignature, msgText string, maxKey int) (retBool bool)
- func MsgTextCleanerCheck(msgText string, maxKey int) (retBool bool)
- func MsgTextToHtml(msg string) (retText string, err error)
- func OpenURL(url string) error
- func PostToServer(serverApiUrl, serverToken string, postData interface{}) (ret []byte, err error)
- func PostToServerEx(serverApiUrl, serverToken string, postData interface{}) (ret string, err error)
- func RandTimeMinute(n int64) time.Duration
- func RandTimeSecond(n int64) time.Duration
- func ReadFile(path string) (retByte []byte, err error)
- func RemoveFile(filePath string) error
- func RemoveRep(slc []string) []string
- func RemoveRepByLoop(slc []string) []string
- func RemoveRepByMap(slc []string) []string
- func RightStr(str, posStr string, isContainsPosStr bool) string
- func RuneIndex(p []byte, n int) (int, bool)
- func RuneIndexInString(s string, n int) (int, bool)
- func RuneSub(p []byte, start, length int) []byte
- func RuneSubString(s string, start, length int) string
- func SleepRandTimeMinute(n int64)
- func SleepRandTimeSecond(n int64)
- func StructToMap(data interface{}) map[string]interface{}
- func SubStrDecodeRuneInString(s string, length int) string
- func SubStrRange(s string, length int) string
- func SubStrRuneN(textStr string, n int) (retText string)
- func TbkPidParse(pid string) (siteID, adzoneID string)
- func TimeStampNow() int64
- func TimeStampNowEx(isSecond bool) int64
- func TinyURLAPI(langURL, apiBaseURL string, timeDuration time.Duration, isJson bool) (retText string, err error)
- func TrimEmoji(s string) string
- func TrimHtml(src string) string
- func UnGzip(byte []byte) []byte
- func UnicodeEmojiCode(s string) string
- func UnicodeEmojiDecode(s string) string
- func UrlMapToTGHTML(urlMap map[string]string) (ret string, err error)
- func UrlPatchHttp(url string) (ret string)
- func UrlRegMatchReplace(str string) (ret string)
- func UrlRegMatchReplaceToMarkdown(str string) (ret string)
- func UrlRegMatchReplaceToTGHTML(str string) (ret string, err error)
- func UrlTextToMap(urlText string) (ret map[string]string, err error)
- func Utf8ToGb18030(s []byte) ([]byte, error)
- func Utf8ToGb18030String(s string) string
- func VerifyEmailFormat(email string) bool
- func VerifyMobileFormat(mobileNum string) bool
- func VerifyNameFormat(name string) bool
- func WriteFile(filePath string, fileBody []byte) error
- type BCounter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64StdEncodingDecode ¶
func CreateUUID ¶
生成随机UUID(RFC 4122) create a random UUID with from RFC 4122 adapted from http://github.com/nu7hatch/gouuid
func CrosscheckKey ¶
检查 key 是否存在 true 真 存在,false 不存在/或key为空,不存在存储
func CrosscheckKeyWithBase ¶
func EncryptHmacSha256 ¶
func EncryptHmacmd5 ¶
https://www.jianshu.com/p/02da10ca45d1 hmac-md5加密
func GB18030String ¶
func Gb18030ToUtf8 ¶
func Gb18030ToUtf8String ¶
func GetAbsPath ¶
获取绝对路径 tmpName:绝对/相对路径,defaultName:默认路径
func GetRedirectUrl ¶
可还原的链接: 淘宝 https://s.click.taobao.com/rioMXxu 二合一链接 苏宁 https://sugs.suning.com/HpGbzgk6 https://sugs.suning.com/HpCPkl3B 唯品会 https://t.vip.com/MhW6RosYXqA
func GetRedirectUrlEx ¶
可还原的链接: 淘宝 https://m.tb.cn/h.52VLTIe 淘宝 https://s.click.taobao.com/rioMXxu 二合一链接 苏宁 https://sugs.suning.com/HpGbzgk6 https://sugs.suning.com/HpCPkl3B 唯品会 https://t.vip.com/MhW6RosYXqA 拼多多 https://p.pinduoduo.com/IE9vjwqh 考拉 https://lu.kaola.com/gKGdm
func GetRedirectUrlJD ¶
可还原的链接: https://u.jd.com/K7oUzZ
func GetRedirectUrlWithTCN ¶
还原新浪短链接 urlOrg, err := util.GetRedirectUrlEx("http://t.cn/A6c2Ka9G", false) fmt.Println(err, urlOrg) urlOrg, err = util.GetRedirectUrlEx(urlOrg, false) fmt.Println(err, urlOrg)
func GetRel ¶
https://www.cnblogs.com/malukang/p/12907945.html GetRel(uploadDir,uploadFilePath) 获取相对路径
func GetTextCleaner ¶
func GetUrlToByte ¶
func GetUrlToByteEx ¶
func GetUrlToString ¶
func GetUrlToStringEx ¶
func IsExist ¶
判断文件/目录是否存在 IsExist checks whether a file or directory exists. It returns false when the file or directory does not exist.
func IsFile ¶
区分目录和文件 IsFile checks whether the path is a file, it returns false when it's a directory or does not exist.
func JsonDecode ¶
func JsonDecodeByte ¶
func JsonDecodeString ¶
func JsonEncode ¶
func JsonEncode(data interface{}) string
func JsonEncodeMapToByte ¶
func KeyworldListParseToArrMap ¶
解析 k>>kc|k1>>kc1 到 arr map
func KeyworldListParseToMap ¶
解析 k>>kc|k1>>kc1 到 map
func MsgSignatureCheck ¶
检查 msgmsgSignature 是否已记录 true 真 存在,false 不存在,不存在存储
func MsgSignatureCheckEx ¶
检查 msgmsgSignature 是否已记录 true 真 存在,false 不存在,不存在存储
func MsgTextCleanerCheck ¶
func MsgTextToHtml ¶
func PostToServer ¶
func PostToServerEx ¶
func RemoveFile ¶
func RuneIndex ¶
RuneIndex 返回 p 中第 n 个字符的位置索引,可以通过索引位置截取 []byte 如果 n 超过 p 中字符的数量,则第二个参数返回 false 错误的或短的编码被当做宽度为一个字节的单一字符。
func RuneIndexInString ¶
RuneIndexInString 返回 s 中第 n 个字符的位置索引,可以通过索引位置截取字符串 如果 n 超过 s 中字符的数量,则第二个参数返回 false 错误的或短的编码被当做宽度为一个字节的单一字符。
func RuneSub ¶
RuneSub 提供符文数量截取字节数组的方法,针对多字节字符安全高效的截取 如果 start 是非负数,返回的字符串将从 string 的 start 位置开始,从 0 开始计算。例如,在字符串 “abcdef” 中,在位置 0 的字符是 “a”,位置 2 的字符串是 “c” 等等。 如果 start 是负数,返回的字符串将从 string 结尾处向前数第 start 个字符开始。 如果 string 的长度小于 start,将返回空字符串。
如果提供了正数的 length,返回的字符串将从 start 处开始最多包括 length 个字符(取决于 string 的长度)。 如果提供了负数的 length,那么 string 末尾处的 length 个字符将会被省略(若 start 是负数则从字符串尾部算起)。如果 start 不在这段文本中,那么将返回空字符串。 如果提供了值为 0 的 length,返回的子字符串将从 start 位置开始直到字符串结尾。
func RuneSubString ¶
RuneSubString 提供符文数量截取字符串的方法,针对多字节字符安全高效的截取 如果 start 是非负数,返回的字符串将从 string 的 start 位置开始,从 0 开始计算。例如,在字符串 “abcdef” 中,在位置 0 的字符是 “a”,位置 2 的字符串是 “c” 等等。 如果 start 是负数,返回的字符串将从 string 结尾处向前数第 start 个字符开始。 如果 string 的长度小于 start,将返回空字符串。
如果提供了正数的 length,返回的字符串将从 start 处开始最多包括 length 个字符(取决于 string 的长度)。 如果提供了负数的 length,那么 string 末尾处的 length 个字符将会被省略(若 start 是负数则从字符串尾部算起)。如果 start 不在这段文本中,那么将返回空字符串。 如果提供了值为 0 的 length,返回的子字符串将从 start 位置开始直到字符串结尾。
func StructToMap ¶
func StructToMap(data interface{}) map[string]interface{}
func SubStrRange ¶
func TbkPidParse ¶
func TimeStampNowEx ¶
fmt.Println(time.Now().Unix()) fmt.Println(time.Now().UnixNano() / 1e6) 13位时间戳 UnixMilli isSecond=true 返回10位时间戳。isSecond=false 返回13位时间戳
func TinyURLAPI ¶
func TinyURLAPI(langURL, apiBaseURL string, timeDuration time.Duration, isJson bool) (retText string, err error)
长链接转短链接 http://127.0.0.1:8089/tinyURL?url=http://www.lyhuilin.com {"code":0,"message":"OK","data":{"url":"http://www.lyhuilin.com","short_url":"https://u.nav.xin/4i"}}
func UrlMapToTGHTML ¶
hanMap := make(map[string]string, 0) hanMap["汉//\\字"] = "http://han.com" hanMap["汉.df||字2"] = "http://han2.com" ret, err := util.UrlMapToTGHTML(hanMap)
if err != nil { fmt.Println("出错了", err) } else { fmt.Println("ret", ret) }
urlMap[title]url,转义,输出为TG支持的HTML格式文案
func UrlRegMatchReplace ¶
func UrlRegMatchReplaceToTGHTML ¶
识别文案中链接,并转义,输出为TG支持的HTML格式文案
func Utf8ToGb18030 ¶
func Utf8ToGb18030String ¶
Types ¶
type BCounter ¶
type BCounter struct {
// contains filtered or unexported fields
}
var Counter *BCounter
计数器
func (*BCounter) IsNiceWithNum ¶
Source Files ¶
- base64.go
- check_ping.go
- clear_url.go
- common.go
- counter.go
- crypto.hmac.sha256.go
- crypto.sha1.hmac.md5.go
- emoji.go
- file.go
- file.path.2.go
- file.path.go
- gb18030_utf8.go
- get_safe_html.go
- get_text_cleaner_hash.go
- json.string.go
- key_crosscheck.go
- keyworld_parse.go
- msg.text.to.html.go
- open_url.go
- post_to_server.go
- rand.go
- remove_file.go
- remove_rep.go
- string.alimama.pid.go
- string.exutf8.go
- string.go
- string.html.go
- string.substr.go
- time.go
- time_sleep.go
- tiny_url_api.go
- url.get.redirect.url.go
- url.get.redirect.url.jd.go
- url.http.get.go
- url.regexp.match.replace.go
- url_match_parse_to_map.go
- usc2.go
- util.go
- uuid.go
- verify.go