22 lines
487 B
Go
22 lines
487 B
Go
package util
|
|
|
|
// Takes a slice of strings as from reading each line in a file.
|
|
// Concatenates strings, creating new ones when blank lines are encountered
|
|
// NB: adds a single space to the beginning of each concatenated line.
|
|
func SplitOnBlankLine(input []string) []string {
|
|
converted := []string{}
|
|
|
|
current := ""
|
|
for _, line := range input {
|
|
if line == "" {
|
|
converted = append(converted, current)
|
|
current = ""
|
|
continue
|
|
}
|
|
|
|
current += " " + line
|
|
}
|
|
|
|
return converted
|
|
}
|