Skip to content

Commit 5820761

Browse files
authored
Update slice.go
1 parent f6b0046 commit 5820761

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

slice.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ func SliceRemoveCallback(length int, callback func(int) func(bool) error) error
561561

562562
func SplitKVRows(rows string, seperator ...string) map[string]string {
563563
sep := `=`
564-
if len(seperator) > 0 {
564+
if len(seperator) > 0 && len(seperator[0]) > 0 {
565565
sep = seperator[0]
566566
}
567567
res := map[string]string{}
@@ -582,7 +582,7 @@ func SplitKVRows(rows string, seperator ...string) map[string]string {
582582

583583
func SplitKVRowsCallback(rows string, callback func(k, v string) error, seperator ...string) (err error) {
584584
sep := `=`
585-
if len(seperator) > 0 {
585+
if len(seperator) > 0 && len(seperator[0]) > 0 {
586586
sep = seperator[0]
587587
}
588588
for _, row := range strings.Split(rows, StrLF) {
@@ -604,8 +604,9 @@ func SplitKVRowsCallback(rows string, callback func(k, v string) error, seperato
604604
}
605605

606606
func TrimSpaceForRows(rows string) []string {
607-
res := []string{}
608-
for _, row := range strings.Split(rows, StrLF) {
607+
rows := strings.Split(rows, StrLF)
608+
res := make([]string, 0, len(rows))
609+
for _, row := range rows {
609610
row = strings.TrimSpace(row)
610611
if len(row) == 0 {
611612
continue

0 commit comments

Comments
 (0)