obtain user login device information

This commit is contained in:
landaiqing
2024-09-02 02:24:46 +08:00
parent 6e47e72514
commit a925bbc871
19 changed files with 327 additions and 46 deletions

21
utils/ip2location.go Normal file
View File

@@ -0,0 +1,21 @@
package utils
import (
"regexp"
"strings"
)
func RemoveZeroAndAdjust(s string) string {
// 正则表达式匹配 "|0|" 或 "|0" 或 "0|" 并替换为 "|"
re := regexp.MustCompile(`(\|0|0\||0)`)
result := re.ReplaceAllString(s, "|")
// 移除可能出现的连续 "|"
re = regexp.MustCompile(`\|+`)
result = re.ReplaceAllString(result, "|")
// 移除字符串开头和结尾可能出现的 "|"
result = strings.Trim(result, "|")
return result
}