code: func (dst *Set) Lookup(d string) (digest.Digest, error) {
  	dst.mutex.RLock()
  	defer dst.mutex.RUnlock()
  	if len(dst.entries) == 0 {
  		return "", ErrDigestNotFound
  	}
  	var (
  		searchFunc func(int) bool
  		alg        digest.Algorithm
  		hex        string
  	)
  	dgst, err := digest.Parse(d)
  	if err == digest.ErrDigestInvalidFormat {
  		hex = d
  		searchFunc = func(i int) bool {
  			return dst.entries[i].val >= d
  		}
  	} else {
  		hex = dgst.Hex()
  		alg = dgst.Algorithm()
  		searchFunc = func(i int) bool {
  			if dst.entries[i].val == hex {
  				return dst.entries[i].alg >= alg
  			}
  			return dst.entries[i].val >= hex
  		}
  	}
  	idx := sort.Search(len(dst.entries), searchFunc)
  	if idx == len(dst.entries) || !checkShortMatch(dst.entries[idx].alg, dst.entries[idx].val, string(alg), hex) {
  		return "", ErrDigestNotFound
  	}
  	if dst.entries[idx].alg == alg && dst.entries[idx].val == hex {
  		return dst.entries[idx].digest, nil
  	}
  	if idx+1 < len(dst.entries) && checkShortMatch(dst.entries[idx+1].alg, dst.entries[idx+1].val, string(alg), hex) {
  		return "", ErrDigestAmbiguous
  	}
  
  	return dst.entries[idx].digest, nil
  }
docs: // Lookup looks for a digest matching the given string representation.
  // If no digests could be found ErrDigestNotFound will be returned
  // with an empty digest value. If multiple matches are found
  // ErrDigestAmbiguous will be returned with an empty digest value.