DeriveId generate an Id from the serialization of the object or part of the object.
(data []byte)
| 20 | |
| 21 | // DeriveId generate an Id from the serialization of the object or part of the object. |
| 22 | func 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 |
| 31 | func (i Id) String() string { |
no test coverage detected