aboutsummaryrefslogtreecommitdiff
path: root/internal/util/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/util/util.go')
-rw-r--r--internal/util/util.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/util/util.go b/internal/util/util.go
index 36d7ea2..f8f12ba 100644
--- a/internal/util/util.go
+++ b/internal/util/util.go
@@ -3,6 +3,7 @@ package util
import (
"math/rand" // not crypto secure
"regexp"
+ "strings"
)
const randHostnameCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"
@@ -33,3 +34,17 @@ func RandomStringFromCharset(charset string, length int) string {
}
return string(b)
}
+
+func RandomStringIfBlank(s string) string {
+ if s == "" {
+ return RandomString()
+ }
+ return s
+}
+
+func CheckNullString(s string) string {
+ if !strings.HasSuffix(s, "\x00") {
+ return s + "\x00"
+ }
+ return s
+}