MCPcopy Index your code
hub / github.com/git-bug/git-bug / DeriveId

Function DeriveId

entity/id.go:22–28  ·  view source on GitHub ↗

DeriveId generate an Id from the serialization of the object or part of the object.

(data []byte)

Source from the content-addressed store, hash-verified

20
21// DeriveId generate an Id from the serialization of the object or part of the object.
22func DeriveId(data []byte) Id {
23 // My understanding is that sha256 is enough to prevent collision (git use that, so ...?)
24 // If you read this code, I'd be happy to be schooled.
25
26 sum := sha256.Sum256(data)
27 return Id(fmt.Sprintf("%x", sum))
28}
29
30// String return the identifier as a string
31func (i Id) String() string {

Callers 9

IdMethod · 0.92
UnmarshalJSONMethod · 0.92
WriteMethod · 0.92
IdMethod · 0.92
WriteMethod · 0.92
readOperationPackFunction · 0.92
unmarshallPackFunction · 0.92
IdOperationFunction · 0.92
SerializeRoundTripTestFunction · 0.92

Calls 1

IdTypeAlias · 0.85

Tested by

no test coverage detected