id

package
v0.0.0-...-63c1e96 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: GPL-3.0 Imports: 2 Imported by: 4

Documentation

Overview

Package id generates random n-digit IDs.

Index

Constants

View Source
const (
	AlphanumCaseSensitiveDigits   = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ123456789"
	AlphanumCaseInsensitiveDigits = "ABCDEFGHJKLMNPQRSTUVWXYZ123456789"
)

Variables

This section is empty.

Functions

func New

func New(length int, charset string) string

New returns a randomly created ID string. It is not guaranteed to be unique.

Risk estimation can look like this, assuming six AlphanumCaseInsensitiveDigits and five tries:

33^6 ≈ 10^9 different combinations
/ 10^6 purchases
= 10^-3 risk of individual ID being not unique
^ 5 because we do five tries
= 10^-15 risk of none of five IDs being not unique
/ 10^6 purchases
= 10^-9 overall risk of failing

Types

This section is empty.

Jump to

Keyboard shortcuts

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