namegen

package
v0.0.0-...-0fea6e1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package namegen produces random workspace names of the form "<adjective>-<noun>" (e.g., bold-falcon, silent-otter, swift-comet).

The wordlists are short on purpose: 60 × 60 = 3600 combinations is plenty for one developer's worth of in-flight workspaces. The names are pleasant to read, easy to type, and never collide with real branch names (they don't look like "feat/" or "fix-" patterns).

Names are NOT cryptographically random. They use math/rand/v2 with the runtime's default source, which is fine for "give me a memorable label" and inappropriate for anything else.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All() []string

All returns every possible name. Memory cost is small (~3600 strings) and only used by tests; production code should never call this.

func Generate

func Generate() string

Generate returns a fresh "adjective-noun" name using the package-level random source. Two calls with the same source state will produce the same name; callers that care about uniqueness across an existing set should use Unique instead.

func IsValid

func IsValid(s string) bool

IsValid reports whether s could plausibly be a generated name (i.e., matches the "adj-noun" shape using the embedded wordlists). Used by reconciliation to recognize canopy-generated names vs user-supplied --name overrides — the distinction matters for some future v0.5 features.

func Space

func Space() int

Space returns the total number of distinct names this package can produce (|adjectives| × |nouns|). Useful for tests and for "ran out of names" diagnostics.

func Unique

func Unique(used []string) (string, bool)

Unique returns a name that is not present in the used slice. It tries up to maxAttempts times before giving up; with a 3600-name space and realistic workspace counts (<100), collisions are vanishingly rare and maxAttempts=100 is more than sufficient.

Returns the name plus a boolean: true on success, false if maxAttempts were exhausted (which means the wordlist is effectively full — call site should error rather than fall back to a numeric suffix).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL