code: func ObjectRefToInstanceID(ref *api.ObjectRef) string {
  	if err := ValidateObjectRef(ref, AnyHash); err != nil {
  		panic(err)
  	}
  	if ref.HashAlgo == api.HashAlgo_SHA1 {
  		return ref.HexDigest // legacy SHA1 instance ID format
  	}
  	return encodeObjectRef(ref)
  }
docs: // ObjectRefToInstanceID returns an Instance ID that matches the given CAS
  // object ref.
  //
  // Instance ID is a human readable string representation of ObjectRef used in
  // higher level APIs (command line flags, ensure files, etc) and internally in
  // the datastore.
  //
  // Its exact form depends on a hash being used:
  //   * SHA1: Instance IDs are hex encoded SHA1 digests, in lowercase.
  //   * Everything else: base64(digest + []byte{ref.HashAlgo}), where base64 is
  //     without padding and using URL-safe charset.
  //
  // The ref is not checked for correctness. Use ValidateObjectRef if this is
  // a concern. Panics if something is not right.