code: func EmitMetadataEvents(c context.Context, before, after *api.PrefixMetadata) error {
  	if before.Prefix != after.Prefix {
  		panic(fmt.Sprintf("comparing metadata for different prefixes: %q != %q", before.Prefix, after.Prefix))
  	}
  	prefix := after.Prefix
  
  	prev := metadata.GetACLs(before)
  	next := metadata.GetACLs(after)
  
  	var granted []*api.PrefixMetadata_ACL
  	var revoked []*api.PrefixMetadata_ACL
  
  	for _, role := range sortedRoles {
  		if added := stringSetDiff(next[role], prev[role]); len(added) != 0 {
  			granted = append(granted, &api.PrefixMetadata_ACL{
  				Role:       role,
  				Principals: added,
  			})
  		}
  		if removed := stringSetDiff(prev[role], next[role]); len(removed) != 0 {
  			revoked = append(revoked, &api.PrefixMetadata_ACL{
  				Role:       role,
  				Principals: removed,
  			})
  		}
  	}
  
  	if len(granted) == 0 && len(revoked) == 0 {
  		return nil
  	}
  
  	return EmitEvent(c, &api.Event{
  		Kind:        api.EventKind_PREFIX_ACL_CHANGED,
  		Package:     prefix,
  		GrantedRole: granted,
  		RevokedRole: revoked,
  	})
  }
docs: // EmitMetadataEvents compares two metadatum of a prefix and emits events for
  // fields that have changed.