33 lines
468 B
Go
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
|
||
|
}
|