Get taxonomy

Retrieve existing taxonomy.

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.

import (

	datacatalog ""
	datacatalogpb ""

// getTaxonomy prints information about a given taxonomy.
func getTaxonomy(w io.Writer, taxonomyID string) error {
	// taxonomyID := "projects/myproject/locations/us/taxonomies/1234"
	ctx := context.Background()
	policyClient, err := datacatalog.NewPolicyTagManagerClient(ctx)
	if err != nil {
		return fmt.Errorf("datacatalog.NewPolicyTagManagerClient: %v", err)
	defer policyClient.Close()

	req := &datacatalogpb.GetTaxonomyRequest{
		Name: taxonomyID,
	resp, err := policyClient.GetTaxonomy(ctx, req)
	if err != nil {
		return fmt.Errorf("GetTaxonomy: %v", err)
	fmt.Fprintf(w, "Taxonomy %s has Display Name %s and Description: %s\n", resp.Name, resp.DisplayName, resp.Description)
	return nil

What's next

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