32 lines
453 B
Go
32 lines
453 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 {
|
|
if strings.HasPrefix(s, separatorComment) {
|
|
return ""
|
|
}
|
|
|
|
return s
|
|
}
|