MCPcopy
hub / github.com/coder/websocket / String

Function String

internal/test/xrand/xrand.go:22–34  ·  view source on GitHub ↗

String generates a random string with length n.

(n int)

Source from the content-addressed store, hash-verified

20
21// String generates a random string with length n.
22func String(n int) string {
23 s := strings.ToValidUTF8(string(Bytes(n)), "_")
24 s = strings.ReplaceAll(s, "\x00", "_")
25 if len(s) > n {
26 return s[:n]
27 }
28 if len(s) < n {
29 // Pad with =
30 extra := n - len(s)
31 return s + strings.Repeat("=", extra)
32 }
33 return s
34}
35
36// Bool returns a randomly generated boolean.
37func Bool() bool {

Callers 5

TestConnFunction · 0.92
assertEchoFunction · 0.92
Test_slidingWindowFunction · 0.92
BenchmarkJSONFunction · 0.92
randMessageFunction · 0.92

Calls 1

BytesFunction · 0.85

Tested by 4

TestConnFunction · 0.74
assertEchoFunction · 0.74
Test_slidingWindowFunction · 0.74
BenchmarkJSONFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…