1 Star 1 Fork 0

wulala乌啦啦/hwpack

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
utils.go 940 Bytes
Copy Edit Raw Blame History
wulala乌啦啦 authored 2021-08-12 23:22 +08:00 . first
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 ""
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wulalade/hwpack.git
git@gitee.com:wulalade/hwpack.git
wulalade
hwpack
hwpack
4a210dae89ef

Search