用户端实现UDP设置/优化检查端口是否已被使用API

This commit is contained in:
刘祥超
2021-11-24 19:46:59 +08:00
parent f4313de55f
commit 6e0a0a099d
9 changed files with 252 additions and 27 deletions

21
internal/utils/strings.go Normal file
View File

@@ -0,0 +1,21 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package utils
import "strings"
// SplitStrings 分隔字符串
// 忽略其中为空的片段
func SplitStrings(s string, glue string) []string {
var result = []string{}
if len(s) > 0 {
for _, p := range strings.Split(s, glue) {
p = strings.TrimSpace(p)
if len(p) > 0 {
result = append(result, p)
}
}
}
return result
}