diff options
| author | 2026-03-07 14:23:34 +0800 | |
|---|---|---|
| committer | 2026-03-07 14:23:34 +0800 | |
| commit | 4a461d214e1a0ea6361516da36b30328ced1917c (patch) | |
| tree | 9072b5bfb363114f59fe05ecd8c5eeecc756a8bd /objectid/objectid.go | |
| parent | internal/compress/flate: Fix formatting bug (diff) | |
| signature | No signature | |
objectid: Add Zero
Diffstat (limited to 'objectid/objectid.go')
| -rw-r--r-- | objectid/objectid.go | 10 |
1 files changed, 10 insertions, 0 deletions
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 |
