diff options
| author | 2026-02-21 00:22:40 +0800 | |
|---|---|---|
| committer | 2026-02-21 00:22:40 +0800 | |
| commit | fe595229e41f9aea5c08d5ab3889804b77a70359 (patch) | |
| tree | 46e623942ab2da1b311131e465ce3739b822d76c | |
| parent | objectdb: Add Reader-based methods (diff) | |
| signature | No signature | |
objectid: Add SupportedAlgorithms
| -rw-r--r-- | objectid/objectid.go | 11 |
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] |
