Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:recycle: kernel/server/port: refactor strings.Split with more optimized strings.SplitSeq (#17274)

iliyaee1b22e3d2bd
diff --git a/kernel/server/port.go b/kernel/server/port.go
index 5ea29b9043..e62321a206 100644
--- a/kernel/server/port.go
+++ b/kernel/server/port.go
@@ -107,8 +107,8 @@ func pidByPort(port string) (ret string) {
return
}
output := string(data)
- lines := strings.Split(output, "\n")
- for _, l := range lines {
+ lines := strings.SplitSeq(output, "\n")
+ for l := range lines {
if strings.Contains(l, "LISTENING") {
l = l[strings.Index(l, "LISTENING")+len("LISTENING"):]
l = strings.TrimSpace(l)
@@ -127,8 +127,8 @@ func pidByPort(port string) (ret string) {
return
}
output := string(data)
- lines := strings.Split(output, "\n")
- for _, l := range lines {
+ lines := strings.SplitSeq(output, "\n")
+ for l := range lines {
if strings.HasPrefix(l, "p") {
l = l[1:]
ret = l