add truncate func

This commit is contained in:
Bryan McNulty
2025-09-29 20:10:02 -05:00
parent ef537963e0
commit a7cf802741
+9 -1
View File
@@ -1,10 +1,11 @@
package util
import (
"github.com/google/uuid"
"math/rand" // not crypto secure
"regexp"
"strings"
"github.com/google/uuid"
)
const randHostnameCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"
@@ -24,6 +25,13 @@ func RandomHostname() (hostname string) {
}
}
func Truncate(s string, n int) string {
if len(s) <= n {
return s
}
return s[:n] + "..."
}
func RandomWindowsTempFile() string {
return `\Windows\Temp\` + strings.ToUpper(uuid.New().String())
}