1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00
Files
stackexchange-dnscontrol/vendor/github.com/andreyvit/diff/trim.go
Tom Limoncelli 4edf360854 get-zones output should work as input into preview (#688)
* Add tests for get-zones
* fix CAA, SSHFP, TLSA and other bugs
* New format for get-zones: "djs" which is js but uses "disco commas"
* Print diffs using github.com/andreyvit/diff

Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
2020-03-10 11:32:47 -04:00

20 lines
555 B
Go

package diff
import (
"strings"
)
// TrimLines applies TrimSpace to each string in the given array.
func TrimLines(input []string) []string {
result := make([]string, 0, len(input))
for _, el := range input {
result = append(result, strings.TrimSpace(el))
}
return result
}
// TrimLinesInString applies TrimSpace to each line in the given string, and returns the new trimmed string. Empty lines are not removed.
func TrimLinesInString(input string) string {
return strings.Join(TrimLines(strings.Split(strings.TrimSpace(input), "\n")), "\n")
}