anchore-oss-update-bot 5b58ec96b7
chore(deps): update Go version (#4773)
Signed-off-by: anchore-oss-update-bot <anchore-oss-update-bot@users.noreply.github.com>
Co-authored-by: anchore-oss-update-bot <anchore-oss-update-bot@users.noreply.github.com>
2026-04-15 10:01:39 -04:00

27 lines
497 B
Go

package artifact
import (
"fmt"
"github.com/gohugoio/hashstructure"
)
// ID represents a unique value for each package added to a package catalog.
type ID string
type Identifiable interface {
ID() ID
}
func IDByHash(obj any) (ID, error) {
f, err := hashstructure.Hash(obj, &hashstructure.HashOptions{
ZeroNil: true,
SlicesAsSets: true,
})
if err != nil {
return "", fmt.Errorf("could not build ID for object=%+v: %w", obj, err)
}
return ID(fmt.Sprintf("%016x", f)), nil
}