digestString := "sha256:5d8ae7166912499825a5a13c860487f6bdb5a924a5d6a8ec6c9bbcdc07f3226b" digest, err := digest.Parse(digestString) if err != nil { // handle error } fmt.Println(digest.Algorithm()) fmt.Println(digest.Hex())
digestString := "sha256:5d8ae7166912499825a5a13c860487f6bdb5a924a5d6a8ec6c9bbcdc07f3226b" digest, err := digest.Parse(digestString) if err != nil { // handle error } digest2, err := digest.FromBytes(digest.Bytes()) if err != nil { // handle error } fmt.Println(digest.Equal(digest2))In this example, a digest string is parsed using the `Parse` method of the `Digest` type. Then, a new digest is created from the bytes of the original digest using the `FromBytes` method. Finally, the `Equal` method is used to compare the two digests for equality. The package library for this code is `github.com/docker/distribution/digest`.