Fetch the repository succeeded.
package utils
import (
"net"
"strconv"
"strings"
)
func GetuIntString(digit uint) string {
return strconv.Itoa(int(digit))
}
func GetBetweenStr(str, start, end string) string {
n := strings.Index(str, start)
if n == -1 {
n = 0
} else {
n = n + len(start) // 增加了else,不加的会把start带上
}
str = string([]byte(str)[n:])
m := strings.Index(str, end)
if m == -1 {
m = len(str)
}
str = string([]byte(str)[:m])
return str
}
func GetIpFormXaddr(xaddr string) string {
s := strings.Index(xaddr, "http://")
if s == -1 {
return ""
}
xaddr = string([]byte(xaddr)[s+len("http://"):])
//fmt.Println(xaddr[0:])
e := strings.Index(xaddr, "/")
if e == -1 {
return ""
}
if net.ParseIP(xaddr[0:e]) != nil {
return xaddr[0:e]
}
mid := strings.Index(xaddr, ":")
if mid == -1 {
return ""
}
if net.ParseIP(xaddr[0:mid]) != nil {
//fmt.Println(xaddr[0:mid])
return xaddr[0:mid]
}
return ""
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。