MCPcopy
hub / github.com/segmentio/ksuid / Next

Method Next

sequence.go:31–39  ·  view source on GitHub ↗

Next produces the next KSUID in the sequence, or returns an error if the sequence has been exhausted.

()

Source from the content-addressed store, hash-verified

29// Next produces the next KSUID in the sequence, or returns an error if the
30// sequence has been exhausted.
31func (seq *Sequence) Next() (KSUID, error) {
32 id := seq.Seed // copy
33 count := seq.count
34 if count > math.MaxUint16 {
35 return Nil, errors.New("too many IDs were generated")
36 }
37 seq.count++
38 return withSequenceNumber(id, uint16(count)), nil
39}
40
41// Bounds returns the inclusive min and max bounds of the KSUIDs that may be
42// generated by the sequence. If all ids have been generated already then the

Callers 3

TestSequenceFunction · 0.95

Calls 1

withSequenceNumberFunction · 0.85

Tested by 3

TestSequenceFunction · 0.76