v5.0.0
What’s Changed
- Add explicit UUID generation with
NewV4,NewV5, andNewV7, including time-sortable short UUIDs, by @lithammer in #84 - Add
UUIDv5and the standard DNS, URL, OID, and X.500 namespace IDs by @lithammer in #84 - Add reusable custom-alphabet encoders with
NewEncoderby @lithammer in #84 - Replace
github.com/google/uuidwith Go’s standard libraryuuidpackage, leaving shortuuid with no dependencies, by @lithammer in #84 - Speed up reusable custom-alphabet encoding and decoding by precomputing lookup tables by @lithammer in #86
Migrating from v4
v5 requires Go 1.27 and uses the module path:
import "github.com/lithammer/shortuuid/v5"Custom Encoder implementations must use the standard library uuid.UUID type instead of github.com/google/uuid.UUID. Both types have the same [16]byte representation, so values can be converted directly.
NewWithNamespace, NewWithEncoder, and NewWithAlphabet still work but are deprecated. Prefer explicit versions and reusable encoders:
shortuuid.NewV5(shortuuid.NameSpaceDNS, "example.com")
enc := shortuuid.NewEncoder(alphabet)
enc.Encode(uuid.NewV7())Existing encoding and deterministic ID outputs remain unchanged. New also keeps its current v4 behavior.
On an Apple M2 with Go 1.27, reusable custom-alphabet benchmarks took 21% less time for base16 encoding, 49% less for multibyte base16 encoding, and 52% less for multibyte decoding compared with v4.3.0. The deprecated NewWithAlphabet took 26% longer with a multibyte alphabet because it rebuilds the new lookup tables on every call; build one NewEncoder and reuse it.
Full Changelog: v4.3.0...v5.0.0