aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/utilities/utilities.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/utilities/utilities.go b/pkg/utilities/utilities.go
index 6be4e58..bda3034 100644
--- a/pkg/utilities/utilities.go
+++ b/pkg/utilities/utilities.go
@@ -7,6 +7,7 @@ import (
"math/rand"
"os"
"time"
+ "unicode/utf8"
"github.com/spf13/viper"
)
@@ -38,3 +39,11 @@ func DoesFilesExist(files []string) []string {
return nonExistant
}
+
+func TrimLastChar(s string) string {
+ r, size := utf8.DecodeLastRuneInString(s)
+ if r == utf8.RuneError && (size == 0 || size == 1) {
+ size = 0
+ }
+ return s[:len(s)-size]
+}