- Early
nil
checks toGenerator
methods
- Improved documentation about generator's clock rollback behavior
- Renamed source files: generator -> gen, identifier -> id
Most notably, v3 switches the letter case of generated IDs from uppercase (e.g., "036Z951MHJIKZIK2GSL81GR7L") to lowercase (e.g., "036z951mhjikzik2gsl81gr7l"), though it is technically not supposed to break existing code because SCRU128 is a case-insensitive scheme. Other changes include the removal of deprecated APIs.
- Deprecated items:
Generator#GenerateCore()
Generator#LastStatus()
andGeneratorStatus
- Letter case of generated IDs from uppercase to lowercase
- Edge case behavior of generator functions' rollback allowance handling
- Upgraded minimum Go version to 1.20
- Error values returned by
Generator
andId
to improve error messages
- Tweaked docs and tests
GenerateOrAbort()
andGenerateOrAbortCore()
toGenerator
(formerly named asGenerateNoRewind()
andGenerateCoreNoRewind()
)Generator#GenerateOrResetCore()
Generator#GenerateCore()
Generator#LastStatus()
andGeneratorStatus
GenerateNoRewind()
andGenerateCoreNoRewind()
toGenerator
(experimental)
- Improved documentation about generator method flavors
UnmarshalBinary()
behavior so it tries to parse byte slice also as textual representation, not only as 128-bit byte arrayUnmarshalText()
andUnmarshalBinary()
ofId
now return error instead of panicking when called with nil receiver
sql.Scanner
interface implementation toId
GenerateCore()
to updatecounter_hi
whentimestamp
passed < 1000
GenerateCore()
to reject zero astimestamp
value
GenerateCore()
andLastStatus()
toGenerator
- Updated README
- Textual representation: 26-digit Base32 -> 25-digit Base36
- Field structure: {
timestamp
: 44 bits,counter
: 28 bits,per_sec_random
: 24 bits,per_gen_random
: 32 bits } -> {timestamp
: 48 bits,counter_hi
: 24 bits,counter_lo
: 24 bits,entropy
: 32 bits } - Timestamp epoch: 2020-01-01 00:00:00.000 UTC -> 1970-01-01 00:00:00.000 UTC
- Counter overflow handling: stall generator -> increment timestamp
- Type of generator: Generator interface -> *Generator struct
Logger
as counter overflow is no longer likely to occurTimestampBias
Id#Counter()
,Id#PerSecRandom()
,Id#PerGenRandom()
Id#CounterHi()
,Id#CounterLo()
,Id#Entropy()
- Initial stable release.