We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ef53796 commit a7cf802Copy full SHA for a7cf802
1 file changed
internal/util/util.go
@@ -1,10 +1,11 @@
1
package util
2
3
import (
4
- "github.com/google/uuid"
5
"math/rand" // not crypto secure
6
"regexp"
7
"strings"
+
8
+ "github.com/google/uuid"
9
)
10
11
const randHostnameCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"
@@ -24,6 +25,13 @@ func RandomHostname() (hostname string) {
24
25
}
26
27
28
+func Truncate(s string, n int) string {
29
+ if len(s) <= n {
30
+ return s
31
+ }
32
+ return s[:n] + "..."
33
+}
34
35
func RandomWindowsTempFile() string {
36
return `\Windows\Temp\` + strings.ToUpper(uuid.New().String())
37
0 commit comments