Skip to content

Commit

Permalink
Add TrimBlankLine function. Closes #79
Browse files Browse the repository at this point in the history
  • Loading branch information
kaidaguerre committed Nov 8, 2023
1 parent 3a09b29 commit 0c6ec1c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions helpers/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,10 @@ func PadRight(str string, length int, pad byte) string {
}
return buf.String()
}

// TrimBlankLines removes any empty lines from the string
func TrimBlankLines(str string) string {
lines := strings.Split(str, "\n")
strippedLines := RemoveFromStringSlice(lines, "")
return strings.Join(strippedLines, "\n")
}

0 comments on commit 0c6ec1c

Please sign in to comment.