code: func encodeObjectRef(ref *api.ObjectRef) string {
  	switch {
  	case ref.HashAlgo < 0:
  		panic(fmt.Errorf("bad negative hash algo %d", ref.HashAlgo))
  	case ref.HashAlgo == 0:
  		panic(fmt.Errorf("unspecified hash algo"))
  	}
  
  	// If algo is known to us, make sure it is valid. Otherwise just encode what
  	// we've given, assuming the consumer will eventually understand it.
  	if int(ref.HashAlgo) < len(supportedAlgos) {
  		if prop := supportedAlgos[ref.HashAlgo]; len(ref.HexDigest) != prop.hexDigestLen {
  			panic(fmt.Errorf("wrong hex digest len %d for algo %s", len(ref.HexDigest), ref.HashAlgo))
  		}
  	}
  
  	blob, err := hex.DecodeString(ref.HexDigest)
  	if err != nil {
  		panic(fmt.Errorf("bad hex digest %q - %s", ref.HexDigest, err))
  	}
  	blob = append(blob, byte(ref.HashAlgo))
  	return base64.RawURLEncoding.EncodeToString(blob)
  }
docs: ////////////////////////////////////////////////////////////////////////////////
  // encodeObjectRef returns a compact stable human-readable serialization of
  // ObjectRef.
  //
  // It takes the digest blob, appends a byte with ref.HashAlgo value to it, and
  // encodes the resulting blob using raw URL-safe base64 encoding.
  //
  // Panics if ref is invalid.