aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-02-21 00:22:40 +0800
committerGravatar Runxi Yu2026-02-21 00:22:40 +0800
commitfe595229e41f9aea5c08d5ab3889804b77a70359 (patch)
tree46e623942ab2da1b311131e465ce3739b822d76c
parentobjectdb: Add Reader-based methods (diff)
signatureNo signature
objectid: Add SupportedAlgorithms
-rw-r--r--objectid/objectid.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/objectid/objectid.go b/objectid/objectid.go
index f97fd197..4058bc20 100644
--- a/objectid/objectid.go
+++ b/objectid/objectid.go
@@ -69,13 +69,16 @@ var algorithmTable = [...]algorithmDetails{
}
var algorithmByName = map[string]Algorithm{}
+var supportedAlgorithms []Algorithm
func init() {
for algo, info := range algorithmTable {
if info.name == "" {
continue
}
- algorithmByName[info.name] = Algorithm(algo)
+ parsed := Algorithm(algo)
+ algorithmByName[info.name] = parsed
+ supportedAlgorithms = append(supportedAlgorithms, parsed)
}
}
@@ -83,6 +86,12 @@ func (algo Algorithm) info() algorithmDetails {
return algorithmTable[algo]
}
+// SupportedAlgorithms returns all object ID algorithms supported by furgit.
+// Do not mutate.
+func SupportedAlgorithms() []Algorithm {
+ return supportedAlgorithms
+}
+
// ParseAlgorithm parses a canonical algorithm name (e.g. "sha1", "sha256").
func ParseAlgorithm(s string) (Algorithm, bool) {
algo, ok := algorithmByName[s]