v1
This commit is contained in:
31
util.go
Normal file
31
util.go
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user