Skip to content

Rewrite as go-randomstring (v1.0.0) - #2

Merged
gbbocchini merged 3 commits into
mainfrom
refactor/go-randomstring
Sep 12, 2026
Merged

gbbocchini merged 3 commits into
mainfrom
refactor/go-randomstring

Conversation

@gbbocchini

Copy link
Copy Markdown
Owner

What changed

Full rewrite of the package, renamed from go-string-randomizer to go-randomstring
(module github.com/gbbocchini/go-randomstring, package randomstring).

Fixes

  • Character-set bug — three collections contained "ABCDEUFGHIJKLMNOPQRSTUVWXYZ"
    (missing F, duplicated U). Sets are now composed from LowerLetters/UpperLetters/Digits,
    so that class of typo can't recur.
  • Deprecated/unsafe RNG — replaced rand.Seed on the global rand with math/rand/v2 local
    sources; no per-call reseeding, goroutine-safe.

New API

r := randomstring.Randomizer{
    Universe: randomstring.LowerUpperDigits,
    Length:   13,
    Unique:   true,  // distinct within a batch
    Secure:   true,  // crypto/rand for passwords/tokens
    Seed:     1,     // deterministic output
}
id, err := r.GenerateOne()
ids, err := r.Generate(10_000)
  • Error-last returns: ([]string, error).
  • UniquePermutations() *big.Int (exact — replaces the float64 version).
  • Crypto-secure mode via the Secure field.
  • ASCII fast path for speed; Unicode universes supported.

Docs & tests

  • pkg.go.dev-ready package doc (doc.go) and doc comments on every exported symbol.
  • Runnable examples (example_test.go) + unit tests + a benchmark.
  • Rewritten README with badges, install, and usage guide.

🤖 Generated with Claude Code

gbbocchini and others added 3 commits September 12, 2026 17:20
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
@gbbocchini
gbbocchini force-pushed the refactor/go-randomstring branch from c16ec5e to e5e70af Compare September 12, 2026 20:20
@gbbocchini gbbocchini self-assigned this Sep 12, 2026
@gbbocchini
gbbocchini merged commit e4d1d32 into main Sep 12, 2026
1 check passed
@gbbocchini gbbocchini added the enhancement New feature or request label Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant