|
| 1 | +package session |
| 2 | + |
| 3 | +import ( |
| 4 | + "crypto/rand" |
| 5 | + "fmt" |
| 6 | + "math/big" |
| 7 | +) |
| 8 | + |
| 9 | +var adjectives = []string{ |
| 10 | + "amber", "azure", "bold", "brave", "bright", |
| 11 | + "calm", "clear", "cold", "cool", "coral", |
| 12 | + "crisp", "dark", "dawn", "deep", "dry", |
| 13 | + "dusk", "early", "east", "fair", "fast", |
| 14 | + "firm", "flat", "fresh", "frost", "full", |
| 15 | + "glad", "gold", "grand", "gray", "green", |
| 16 | + "half", "high", "hot", "icy", "iron", |
| 17 | + "keen", "kind", "late", "lean", "light", |
| 18 | + "lime", "live", "long", "low", "mild", |
| 19 | + "mint", "mist", "near", "neat", "next", |
| 20 | + "north", "odd", "old", "opal", "open", |
| 21 | + "pale", "peak", "pine", "pink", "plain", |
| 22 | + "prime", "pure", "quiet", "rare", "raw", |
| 23 | + "red", "rich", "ripe", "rose", "ruby", |
| 24 | + "rust", "safe", "sage", "silk", "slim", |
| 25 | + "slow", "soft", "south", "stark", "steel", |
| 26 | + "still", "stone", "sun", "swift", "tall", |
| 27 | + "teal", "thin", "true", "warm", "west", |
| 28 | + "white", "wide", "wild", "wise", "young", |
| 29 | +} |
| 30 | + |
| 31 | +var nouns = []string{ |
| 32 | + "arch", "ash", "bay", "beam", "birch", |
| 33 | + "bloom", "bolt", "brook", "cape", "cave", |
| 34 | + "cedar", "cliff", "cloud", "coast", "cove", |
| 35 | + "crane", "creek", "crest", "crow", "dale", |
| 36 | + "dart", "dawn", "delta", "dove", "drift", |
| 37 | + "dune", "dust", "elm", "ember", "fern", |
| 38 | + "field", "finch", "flame", "flint", "fog", |
| 39 | + "forge", "fox", "frost", "gale", "gate", |
| 40 | + "glen", "grove", "hare", "hawk", "heath", |
| 41 | + "hill", "hive", "hollow", "ivy", "jade", |
| 42 | + "jay", "lake", "lark", "leaf", "ledge", |
| 43 | + "lily", "loft", "maple", "marsh", "mesa", |
| 44 | + "mist", "moss", "moth", "oak", "orbit", |
| 45 | + "otter", "owl", "palm", "path", "peak", |
| 46 | + "pine", "plum", "pond", "quail", "rain", |
| 47 | + "raven", "reef", "ridge", "river", "rock", |
| 48 | + "sage", "shore", "sky", "slope", "snow", |
| 49 | + "spark", "spruce", "star", "stone", "storm", |
| 50 | + "stream", "swift", "thorn", "tide", "trail", |
| 51 | + "vale", "vine", "wave", "willow", "wolf", |
| 52 | +} |
| 53 | + |
| 54 | +// GenerateWordID generates a human-friendly ID in the form "adjective-adjective-noun". |
| 55 | +func GenerateWordID() string { |
| 56 | + adj1 := pickRandom(adjectives) |
| 57 | + adj2 := pickRandom(adjectives) |
| 58 | + noun := pickRandom(nouns) |
| 59 | + return fmt.Sprintf("%s-%s-%s", adj1, adj2, noun) |
| 60 | +} |
| 61 | + |
| 62 | +func pickRandom(list []string) string { |
| 63 | + n, err := rand.Int(rand.Reader, big.NewInt(int64(len(list)))) |
| 64 | + if err != nil { |
| 65 | + // Fallback: just use first element (should never happen) |
| 66 | + return list[0] |
| 67 | + } |
| 68 | + return list[n.Int64()] |
| 69 | +} |
0 commit comments