diff options
| author | Fuwn <[email protected]> | 2021-07-15 22:06:22 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-15 22:06:22 +0000 |
| commit | c2fd318cce371e2563c248fe7d942500a52a0be8 (patch) | |
| tree | 265c2c0a54f71d57bb9d16a8694e489fe364ed5f /pkg | |
| parent | feat(templates): poc for a sysinfo footer item (diff) | |
| download | space-c2fd318cce371e2563c248fe7d942500a52a0be8.tar.xz space-c2fd318cce371e2563c248fe7d942500a52a0be8.zip | |
feat(route): implement a blogging engine
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/utilities/utilities.go | 9 |
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] +} |