MCPcopy Index your code
hub / github.com/coder/coder / NameDigitWith

Function NameDigitWith

coderd/util/namesgenerator/namesgenerator.go:42–46  ·  view source on GitHub ↗

NameDigitWith returns a random name with a two-digit suffix (00-99), in the format "[adjective][delim][surname][digit]" e.g. "happy_smith42". Provides some collision resistance while keeping names short and clean. Not guaranteed to be unique.

(delim string)

Source from the content-addressed store, hash-verified

40// Provides some collision resistance while keeping names short and clean.
41// Not guaranteed to be unique.
42func NameDigitWith(delim string) string {
43 //nolint:gosec // The random digit doesn't need to be cryptographically secure.
44 name := NameWith(delim) + fmt.Sprintf("%02d", rand.IntN(100))
45 return truncate(name, maxNameLen)
46}
47
48// UniqueName returns a random name with a monotonically increasing suffix,
49// guaranteeing uniqueness within the process. The name is truncated to 32

Callers 7

oauthLoginMethod · 0.92
postTokenMethod · 0.92
generatedWorkspaceNameFunction · 0.92
UsernameFromFunction · 0.92
TestNameDigitWithLengthFunction · 0.85

Calls 2

NameWithFunction · 0.85
truncateFunction · 0.85

Tested by 1

TestNameDigitWithLengthFunction · 0.68