diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2019-03-20 23:19:00 +0300 |
---|---|---|
committer | Paul Okstad <pokstad@gitlab.com> | 2019-03-20 23:19:00 +0300 |
commit | 996ac5da5c8cf5de7cb364e07aae49d81eb5eef2 (patch) | |
tree | f4892136fb060e041f8baf013a0360c6b9d3edd8 /internal/helper/text | |
parent | f309a06e14740430380f96f5d2e212b525ca63cf (diff) |
Introduce text.ChompBytes helper
Diffstat (limited to 'internal/helper/text')
-rw-r--r-- | internal/helper/text/chomp.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/helper/text/chomp.go b/internal/helper/text/chomp.go new file mode 100644 index 000000000..6ce64cafa --- /dev/null +++ b/internal/helper/text/chomp.go @@ -0,0 +1,8 @@ +package text + +import "strings" + +// ChompBytes converts b to a string with its trailing newline, if present, removed. +func ChompBytes(b []byte) string { + return strings.TrimSuffix(string(b), "\n") +} |