Files
conf/util.go
Dmitry Fedotov 6d0e13f05e rewrite
2025-04-09 04:57:40 +03:00

33 lines
468 B
Go

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
}