initial commit

This commit is contained in:
wt committed 2025-06-26 18:20:20 +07:00
commit 5ba52dd285
19 files changed
+639

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
package utils
import "strings"
func DecodeHosts(input string) map[string]any {
result := make(map[string]any)
pairs := strings.SplitSeq(input, "\n")
for pair := range pairs {
if pair == "" {
continue
}
kv := strings.Split(pair, " ")
if len(kv) == 2 {
key := strings.TrimSpace(kv[0])
value := strings.TrimSpace(kv[1])
if key != "" {
result[key] = value
}
continue
}
if len(kv) != 0 {
key := strings.TrimSpace(kv[0])
var value []string
for i := 1; i < len(kv); i++ {
value = append(value, kv[i])
}
result[key] = value
}
}
return result
}