Delete policy tag

Delete an existing policy tag.

Code sample


Before trying this sample, follow the Go setup instructions in the Data Catalog quickstart using client libraries. For more information, see the Data Catalog Go API reference documentation.

To authenticate to Data Catalog, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

import (

	datacatalog ""

// deletePolicyTag deletes a given policy tag.
func deletePolicyTag(policyTagID string) error {
	// policyTagID := "projects/myproject/locations/us/taxonomies/1234/policyTags/5678"
	ctx := context.Background()
	policyClient, err := datacatalog.NewPolicyTagManagerClient(ctx)
	if err != nil {
		return fmt.Errorf("datacatalog.NewPolicyTagManagerClient: %w", err)
	defer policyClient.Close()

	req := &datacatalogpb.DeletePolicyTagRequest{
		Name: policyTagID,
	return policyClient.DeletePolicyTag(ctx, req)

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.