### Use Pre-built Suffix Generators Source: https://context7.com/riipandi/memorable-ids/llms.txt Utilizes pre-built suffix generators to add randomized suffixes, increasing ID uniqueness. Each generator returns a pointer to a string. ```go package main import ( "fmt" memorable_ids "github.com/riipandi/memorable-ids" ) func main() { // Number: 3-digit random number (000-999) - adds 1,000x multiplier suffix1 := memorable_ids.SuffixGenerators.Number() fmt.Println(*suffix1) // Output: "042" // Number4: 4-digit random number (0000-9999) - adds 10,000x multiplier suffix2 := memorable_ids.SuffixGenerators.Number4() fmt.Println(*suffix2) // Output: "7891" // Hex: 2-digit hexadecimal (00-ff) - adds 256x multiplier suffix3 := memorable_ids.SuffixGenerators.Hex() fmt.Println(*suffix3) // Output: "a3" // Timestamp: last 4 digits of current timestamp suffix4 := memorable_ids.SuffixGenerators.Timestamp() fmt.Println(*suffix4) // Output: "5823" // Letter: single lowercase letter (a-z) - adds 26x multiplier suffix5 := memorable_ids.SuffixGenerators.Letter() fmt.Println(*suffix5) // Output: "k" // Custom suffix generator customSuffix := func() *string { s := "custom" return &s } id, _ := memorable_ids.Generate(memorable_ids.GenerateOptions{ Components: 2, Suffix: customSuffix, }) fmt.Println(id) // Output: "brave-lion-custom" } ``` -------------------------------- ### Access Complete Dictionary Source: https://context7.com/riipandi/memorable-ids/llms.txt Retrieves the full dictionary object containing all word lists and metadata. Use this for custom validation or manual word selection. ```go package main import ( "fmt" memorable_ids "github.com/riipandi/memorable-ids" ) func main() { dict := memorable_ids.GetDictionary() // Access word lists directly fmt.Printf("First 5 adjectives: %v\n", dict.Adjectives[:5]) // Output: [cute dapper large small long] fmt.Printf("First 5 nouns: %v\n", dict.Nouns[:5]) // Output: [rabbit badger fox chicken bat] fmt.Printf("First 5 verbs: %v\n", dict.Verbs[:5]) // Output: [sing play knit flounder dance] // Validate a word belongs to expected category word := "rabbit" for _, noun := range dict.Nouns { if noun == word { fmt.Printf("'%s' is a valid noun\n", word) break } } // Use stats from dictionary fmt.Printf("\nDictionary stats: %+v\n", dict.Stats) } ``` -------------------------------- ### Generate Memorable IDs with Options Source: https://context7.com/riipandi/memorable-ids/llms.txt Generates a memorable ID using default or custom options for components, separator, and suffix. Use this to create human-readable identifiers for various applications. ```go package main import ( "fmt" memorable_ids "github.com/riipandi/memorable-ids" ) func main() { // Default: 2 components (adjective-noun) id1, _ := memorable_ids.Generate(memorable_ids.GenerateOptions{}) fmt.Println(id1) // Output: "cute-rabbit" // 3 components (adjective-noun-verb) id2, _ := memorable_ids.Generate(memorable_ids.GenerateOptions{Components: 3}) fmt.Println(id2) // Output: "large-fox-swim" // With numeric suffix for increased uniqueness id3, _ := memorable_ids.Generate(memorable_ids.GenerateOptions{ Components: 2, Suffix: memorable_ids.SuffixGenerators.Number, }) fmt.Println(id3) // Output: "quick-mouse-042" // Custom separator id4, _ := memorable_ids.Generate(memorable_ids.GenerateOptions{ Components: 2, Separator: "_", }) fmt.Println(id4) // Output: "warm_duck" // 5 components with hex suffix id5, _ := memorable_ids.Generate(memorable_ids.GenerateOptions{ Components: 5, Suffix: memorable_ids.SuffixGenerators.Hex, Separator: "-", }) fmt.Println(id5) // Output: "bright-owl-fly-quickly-above-a3" } ``` -------------------------------- ### Retrieve Dictionary Statistics Source: https://context7.com/riipandi/memorable-ids/llms.txt Fetches counts for each word category in the dictionary. Useful for calculating the total theoretical capacity of the ID generator. ```go package main import ( "fmt" memorable_ids "github.com/riipandi/memorable-ids" ) func main() { stats := memorable_ids.GetDictionaryStats() fmt.Printf("Adjectives: %d words\n", stats.Adjectives) // Output: 78 fmt.Printf("Nouns: %d words\n", stats.Nouns) // Output: 68 fmt.Printf("Verbs: %d words\n", stats.Verbs) // Output: 40 fmt.Printf("Adverbs: %d words\n", stats.Adverbs) // Output: 27 fmt.Printf("Prepositions: %d words\n", stats.Prepositions) // Output: 26 // Calculate total possible combinations manually total := stats.Adjectives * stats.Nouns * stats.Verbs * stats.Adverbs * stats.Prepositions fmt.Printf("\nMax combinations (5 components): %d\n", total) // Output: 148876320 } ``` -------------------------------- ### Analyze ID Collision Probabilities Source: https://context7.com/riipandi/memorable-ids/llms.txt Calculates collision risks for various ID generation volumes. Use this to determine the optimal number of components and suffix range for your specific requirements. ```go package main import ( "fmt" memorable_ids "github.com/riipandi/memorable-ids" ) func main() { // Analysis for 2 components without suffix analysis := memorable_ids.GetCollisionAnalysis(2, 1) fmt.Printf("Total combinations: %d\n", analysis.TotalCombinations) // Output: 5304 fmt.Println("\nCollision scenarios:") for _, scenario := range analysis.Scenarios { fmt.Printf(" %d IDs: %s probability\n", scenario.IDs, scenario.Percentage) } // Output: // 50 IDs: 0.24% probability // 100 IDs: 0.94% probability // 200 IDs: 3.70% probability // 500 IDs: 21.78% probability // 1000 IDs: 60.72% probability // 2000 IDs: 98.91% probability // Analysis for 3 components with suffix (higher capacity) analysis2 := memorable_ids.GetCollisionAnalysis(3, 1000) fmt.Printf("\n3 components + suffix: %d total combinations\n", analysis2.TotalCombinations) // Output: 212160000 total combinations // Choose configuration based on expected volume expectedIDs := 10000 for _, scenario := range analysis2.Scenarios { if scenario.IDs == expectedIDs { fmt.Printf("For %d IDs: %s collision probability\n", expectedIDs, scenario.Percentage) } } } ``` -------------------------------- ### Access Exported Word Lists Source: https://context7.com/riipandi/memorable-ids/llms.txt Directly access the exported word collections for custom ID generation logic. Ensure you handle random selection if building custom ID formats. ```go package main import ( "fmt" "math/rand" memorable_ids "github.com/riipandi/memorable-ids" ) func main() { // Access exported word lists directly fmt.Printf("Total adjectives: %d\n", len(memorable_ids.Adjectives)) // 78 fmt.Printf("Total nouns: %d\n", len(memorable_ids.Nouns)) // 68 fmt.Printf("Total verbs: %d\n", len(memorable_ids.Verbs)) // 40 fmt.Printf("Total adverbs: %d\n", len(memorable_ids.Adverbs)) // 27 fmt.Printf("Total prepositions: %d\n", len(memorable_ids.Prepositions)) // 26 // Custom ID generation using word lists adj := memorable_ids.Adjectives[rand.Intn(len(memorable_ids.Adjectives))] noun := memorable_ids.Nouns[rand.Intn(len(memorable_ids.Nouns))] verb := memorable_ids.Verbs[rand.Intn(len(memorable_ids.Verbs))] customID := fmt.Sprintf("%s-%s-that-%s", adj, noun, verb) fmt.Printf("Custom ID: %s\n", customID) // Output: "brave-fox-that-explore" // Sample words from each category fmt.Printf("\nSample adjectives: %v\n", memorable_ids.Adjectives[:5]) fmt.Printf("Sample nouns: %v\n", memorable_ids.Nouns[:5]) fmt.Printf("Sample verbs: %v\n", memorable_ids.Verbs[:5]) fmt.Printf("Sample adverbs: %v\n", memorable_ids.Adverbs[:5]) fmt.Printf("Sample prepositions: %v\n", memorable_ids.Prepositions[:5]) } ``` -------------------------------- ### Calculate Total ID Combinations Source: https://context7.com/riipandi/memorable-ids/llms.txt Calculates the total number of unique ID combinations possible for a given number of components and suffix length. Useful for capacity planning. ```go package main import ( "fmt" memorable_ids "github.com/riipandi/memorable-ids" ) func main() { // 1 component (adjectives only): 78 combinations combo1 := memorable_ids.CalculateCombinations(1, 1) fmt.Printf("1 component: %d combinations\n", combo1) // Output: 78 // 2 components (adjective + noun): 5,304 combinations combo2 := memorable_ids.CalculateCombinations(2, 1) fmt.Printf("2 components: %d combinations\n", combo2) // Output: 5304 // 3 components (adjective + noun + verb): 212,160 combinations combo3 := memorable_ids.CalculateCombinations(3, 1) fmt.Printf("3 components: %d combinations\n", combo3) // Output: 212160 // 2 components with 3-digit suffix: 5,304,000 combinations combo4 := memorable_ids.CalculateCombinations(2, 1000) fmt.Printf("2 components + 3-digit suffix: %d combinations\n", combo4) // Output: 5304000 // 5 components (all word types): 148,876,320 combinations combo5 := memorable_ids.CalculateCombinations(5, 1) fmt.Printf("5 components: %d combinations\n", combo5) // Output: 148876320 // 5 components with 4-digit suffix: 1,488,763,200,000 combinations combo6 := memorable_ids.CalculateCombinations(5, 10000) fmt.Printf("5 components + 4-digit suffix: %d combinations\n", combo6) } ``` -------------------------------- ### GetDictionary API Source: https://context7.com/riipandi/memorable-ids/llms.txt Fetches the complete dictionary, providing access to all word collections and their associated statistics. ```APIDOC ## GetDictionary ### Description Returns the complete dictionary containing all word collections and their statistics. Useful for custom word selection or validation. ### Method GET (conceptual, as it's a function call) ### Endpoint N/A (Function Call) ### Parameters None ### Request Example (Function call example) ```go memorable_ids.GetDictionary() ``` ### Response #### Success Response (200) - **Adjectives** ([]string) - List of adjectives. - **Nouns** ([]string) - List of nouns. - **Verbs** ([]string) - List of verbs. - **Adverbs** ([]string) - List of adverbs. - **Prepositions** ([]string) - List of prepositions. - **Stats** (struct) - Statistics about the dictionary (same as GetDictionaryStats response). #### Response Example ```json { "Adjectives": ["cute", "dapper", "large", "small", "long", ...], "Nouns": ["rabbit", "badger", "fox", "chicken", "bat", ...], "Verbs": ["sing", "play", "knit", "flounder", "dance", ...], "Adverbs": ["quickly", "slowly", "happily", "sadly", "loudly", ...], "Prepositions": ["on", "in", "at", "for", "with", ...], "Stats": { "Adjectives": 78, "Nouns": 68, "Verbs": 40, "Adverbs": 27, "Prepositions": 26 } } ``` ``` -------------------------------- ### Calculate Combinations Source: https://context7.com/riipandi/memorable-ids/llms.txt Calculates the total number of possible unique ID combinations for a given configuration. Useful for capacity planning and understanding collision risk. ```APIDOC ## Calculate Combinations ### Description Calculates the total number of possible unique ID combinations for a given configuration. Useful for capacity planning and understanding collision risk. ### Method `memorable_ids.CalculateCombinations(components int, suffixLength int) int` ### Parameters #### Path Parameters - **components** (int) - Required - The number of word components in the ID. - **suffixLength** (int) - Required - The maximum length of the numeric suffix (e.g., 1 for single digit, 1000 for 3 digits). ### Response #### Success Response (int) - **combinations** (int) - The total number of unique ID combinations possible. ### Request Example ```go combo1 := memorable_ids.CalculateCombinations(1, 1) combo2 := memorable_ids.CalculateCombinations(2, 1) combo4 := memorable_ids.CalculateCombinations(2, 1000) ``` ### Response Example ```json { "combinations": 78 } { "combinations": 5304 } { "combinations": 5304000 } ``` ``` -------------------------------- ### Word Lists (Exported Variables) Source: https://context7.com/riipandi/memorable-ids/llms.txt Provides direct access to exported word lists (Adjectives, Nouns, Verbs, Adverbs, Prepositions) for custom ID generation and validation. ```APIDOC ## Word Lists (Exported Variables) ### Description Direct access to the word collections for custom ID generation or validation. Each list contains curated English words categorized by part of speech. ### Method Direct Variable Access ### Endpoint N/A (Package Variables) ### Parameters None ### Request Example (Accessing and using variables) ```go // Get total counts len(memorable_ids.Adjectives) len(memorable_ids.Nouns) // Generate a custom ID adj := memorable_ids.Adjectives[rand.Intn(len(memorable_ids.Adjectives))] noun := memorable_ids.Nouns[rand.Intn(len(memorable_ids.Nouns))] customID := fmt.Sprintf("%s-%s", adj, noun) ``` ### Response (Direct access to string slices) - **memorable_ids.Adjectives** ([]string) - List of adjectives. - **memorable_ids.Nouns** ([]string) - List of nouns. - **memorable_ids.Verbs** ([]string) - List of verbs. - **memorable_ids.Adverbs** ([]string) - List of adverbs. - **memorable_ids.Prepositions** ([]string) - List of prepositions. ### Response Example ```go // Sample output when accessing the first 5 adjectives ["cute", "dapper", "large", "small", "long"] ``` ``` -------------------------------- ### GetCollisionAnalysis API Source: https://context7.com/riipandi/memorable-ids/llms.txt Analyzes collision probabilities for ID generation based on the number of components and suffix capacity. Filters out unrealistic scenarios. ```APIDOC ## GetCollisionAnalysis ### Description Returns a comprehensive collision analysis with scenarios for different ID generation volumes. Filters out unrealistic scenarios (>80% of total combinations). ### Method GET (conceptual, as it's a function call) ### Endpoint N/A (Function Call) ### Parameters #### Query Parameters - **components** (int) - Required - The number of word components in the ID. - **suffixCapacity** (int) - Required - The capacity for a potential suffix. ### Request Example (Function call example) ```go memorable_ids.GetCollisionAnalysis(2, 1) ``` ### Response #### Success Response (200) - **TotalCombinations** (int) - The total number of possible unique IDs. - **Scenarios** ([]struct { IDs int Percentage string }) - A list of collision scenarios with the number of IDs and their corresponding collision probability percentage. #### Response Example ```json { "TotalCombinations": 5304, "Scenarios": [ { "IDs": 50, "Percentage": "0.24%" }, { "IDs": 100, "Percentage": "0.94%" } ] } ``` ``` -------------------------------- ### Parse Memorable ID String Source: https://context7.com/riipandi/memorable-ids/llms.txt Parses a memorable ID string into its word components and an optional numeric suffix. Supports custom separators and automatically detects numeric suffixes. ```go package main import ( "fmt" memorable_ids "github.com/riipandi/memorable-ids" ) func main() { // Parse ID without suffix result1 := memorable_ids.Parse("cute-rabbit", "-") fmt.Printf("Components: %v\n", result1.Components) // Output: [cute rabbit] fmt.Printf("Suffix: %v\n", result1.Suffix) // Output: // Parse ID with numeric suffix result2 := memorable_ids.Parse("cute-rabbit-042", "-") fmt.Printf("Components: %v\n", result2.Components) // Output: [cute rabbit] fmt.Printf("Suffix: %s\n", *result2.Suffix) // Output: 042 // Non-numeric last part treated as component result3 := memorable_ids.Parse("large-fox-swim", "-") fmt.Printf("Components: %v\n", result3.Components) // Output: [large fox swim] fmt.Printf("Suffix: %v\n", result3.Suffix) // Output: // Custom separator result4 := memorable_ids.Parse("cute_rabbit_123", "_") fmt.Printf("Components: %v\n", result4.Components) // Output: [cute rabbit] fmt.Printf("Suffix: %s\n", *result4.Suffix) // Output: 123 // Round-trip: generate and parse id, _ := memorable_ids.Generate(memorable_ids.GenerateOptions{ Components: 3, Suffix: memorable_ids.SuffixGenerators.Number, }) parsed := memorable_ids.Parse(id, "-") fmt.Printf("Original ID: %s\n", id) fmt.Printf("Parsed components: %v, suffix: %s\n", parsed.Components, *parsed.Suffix) } ``` -------------------------------- ### Calculate ID Collision Probability Source: https://context7.com/riipandi/memorable-ids/llms.txt Calculates the probability of ID collisions using the Birthday Paradox formula. Useful for understanding risk when generating many IDs. ```go package main import ( "fmt" memorable_ids "github.com/riipandi/memorable-ids" ) func main() { // For 2 components (5,304 total combinations) totalCombinations := memorable_ids.CalculateCombinations(2, 1) // Probability with 50 generated IDs prob50 := memorable_ids.CalculateCollisionProbability(totalCombinations, 50) fmt.Printf("50 IDs: %.2f%% collision probability\n", prob50*100) // Output: ~0.24% // Probability with 100 generated IDs prob100 := memorable_ids.CalculateCollisionProbability(totalCombinations, 100) fmt.Printf("100 IDs: %.2f%% collision probability\n", prob100*100) // Output: ~0.94% // Probability with 500 generated IDs prob500 := memorable_ids.CalculateCollisionProbability(totalCombinations, 500) fmt.Printf("500 IDs: %.2f%% collision probability\n", prob500*100) // Output: ~21.8% // Edge cases prob0 := memorable_ids.CalculateCollisionProbability(1000, 0) fmt.Printf("0 IDs: %.2f%% (always zero)\n", prob0*100) // Output: 0% probMax := memorable_ids.CalculateCollisionProbability(100, 100) fmt.Printf("IDs >= combinations: %.2f%% (guaranteed collision)\n", probMax*100) // Output: 100% } ``` -------------------------------- ### GetDictionaryStats API Source: https://context7.com/riipandi/memorable-ids/llms.txt Retrieves statistics about the word dictionaries used for ID generation, including the count of words for each part of speech. ```APIDOC ## GetDictionaryStats ### Description Returns statistics about the word dictionaries used for ID generation, including counts for each word type. ### Method GET (conceptual, as it's a function call) ### Endpoint N/A (Function Call) ### Parameters None ### Request Example (Function call example) ```go memorable_ids.GetDictionaryStats() ``` ### Response #### Success Response (200) - **Adjectives** (int) - Count of adjectives in the dictionary. - **Nouns** (int) - Count of nouns in the dictionary. - **Verbs** (int) - Count of verbs in the dictionary. - **Adverbs** (int) - Count of adverbs in the dictionary. - **Prepositions** (int) - Count of prepositions in the dictionary. #### Response Example ```json { "Adjectives": 78, "Nouns": 68, "Verbs": 40, "Adverbs": 27, "Prepositions": 26 } ``` ``` -------------------------------- ### Calculate Collision Probability Source: https://context7.com/riipandi/memorable-ids/llms.txt Calculates the probability of ID collisions using the Birthday Paradox formula. Returns a value between 0 and 1 representing collision likelihood. ```APIDOC ## Calculate Collision Probability ### Description Calculates the probability of ID collisions using the Birthday Paradox formula. Returns a value between 0 and 1 representing collision likelihood. ### Method `memorable_ids.CalculateCollisionProbability(totalCombinations int, generatedIDs int) float64` ### Parameters #### Path Parameters - **totalCombinations** (int) - Required - The total number of possible unique ID combinations. - **generatedIDs** (int) - Required - The number of IDs that have been generated. ### Response #### Success Response (float64) - **probability** (float64) - The probability of a collision, a value between 0 and 1. ### Request Example ```go totalCombinations := memorable_ids.CalculateCombinations(2, 1) prob50 := memorable_ids.CalculateCollisionProbability(totalCombinations, 50) prob100 := memorable_ids.CalculateCollisionProbability(totalCombinations, 100) ``` ### Response Example ```json { "probability": 0.0024 } { "probability": 0.0094 } ``` ``` -------------------------------- ### Parse Memorable ID Source: https://context7.com/riipandi/memorable-ids/llms.txt Parses a memorable ID string back into its component parts, automatically detecting numeric suffixes. Returns a ParsedID struct containing word components and an optional suffix. ```APIDOC ## Parse Memorable ID ### Description Parses a memorable ID string back into its component parts, automatically detecting numeric suffixes. Returns a ParsedID struct containing word components and an optional suffix. ### Method `memorable_ids.Parse(id string, separator string) ParsedID` ### Parameters #### Path Parameters - **id** (string) - Required - The memorable ID string to parse. - **separator** (string) - Required - The separator used in the ID string. ### Response #### Success Response (ParsedID) - **Components** ([]string) - The word components of the ID. - **Suffix** (*string) - An optional pointer to the numeric suffix, if present. ### Request Example ```go result1 := memorable_ids.Parse("cute-rabbit", "-") result2 := memorable_ids.Parse("cute-rabbit-042", "-") result4 := memorable_ids.Parse("cute_rabbit_123", "_") ``` ### Response Example ```json { "Components": ["cute", "rabbit"], "Suffix": null } { "Components": ["cute", "rabbit"], "Suffix": "042" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.