NewXID creates an XID with the given timestamp and sequence number.
(ts time.Time, seq uint64)
| 36 | |
| 37 | // NewXID creates an XID with the given timestamp and sequence number. |
| 38 | func NewXID(ts time.Time, seq uint64) XID { |
| 39 | timePart := fmt.Sprintf("%020d", ts.Unix()) |
| 40 | sequencePart := fmt.Sprintf("%020d", seq) |
| 41 | |
| 42 | return XID(strings.Join([]string{timePart, sequencePart}, "-")) |
| 43 | } |
| 44 | |
| 45 | // NewTimeXID creates an XID with the given timestamp. To get the first or the last |
| 46 | // XID in this timestamp, use the First() or the Last() methods. This is especially |