From 4a461d214e1a0ea6361516da36b30328ced1917c Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 7 Mar 2026 14:23:34 +0800 Subject: objectid: Add Zero --- objectid/objectid.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'objectid') diff --git a/objectid/objectid.go b/objectid/objectid.go index 1c169b29..8eb82969 100644 --- a/objectid/objectid.go +++ b/objectid/objectid.go @@ -59,6 +59,16 @@ func Compare(left, right ObjectID) int { return bytes.Compare(left.RawBytes(), right.RawBytes()) } +// Zero returns the all-zero object ID for the specified algorithm. +func Zero(algo Algorithm) ObjectID { + id, err := FromBytes(algo, make([]byte, algo.Size())) + if err != nil { + panic(err) + } + + return id +} + // ParseHex parses an object ID from hex for the specified algorithm. func ParseHex(algo Algorithm, s string) (ObjectID, error) { var id ObjectID -- cgit v1.3.1-10-gc9f91