This commit is contained in:
Dmitry Fedotov
2025-04-09 04:57:40 +03:00
parent b88b2fd5e6
commit 6d0e13f05e
11 changed files with 700 additions and 604 deletions

32
util.go Normal file
View File

@@ -0,0 +1,32 @@
package conf
import "strings"
const (
separatorComment = "#"
separatorKV = "="
)
func toKV(s string, sep string) (string, string, bool) {
k, v, ok := strings.Cut(s, sep)
if !ok || k == "" || v == "" {
return "", "", false
}
return trim(k), trim(v), true
}
func trim(s string) string {
s = strings.TrimSpace(s)
return s
}
func stripComment(s string) string {
idx := strings.Index(s, separatorComment)
if idx > -1 {
s = s[:idx]
}
return s
}