Retrieve existing taxonomy.

## Code sample

### Go


Before trying this sample, follow the Go setup instructions in the
[Data Catalog quickstart using
client libraries](https://docs.cloud.google.com/data-catalog/docs/reference/libraries).


For more information, see the
[Data Catalog Go API
reference documentation](https://godoc.org/cloud.google.com/go/datacatalog).


To authenticate to Data Catalog, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

    import (
    	"context"
    	"fmt"
    	"io"

    	datacatalog "cloud.google.com/go/datacatalog/apiv1beta1"
    	"cloud.google.com/go/datacatalog/apiv1beta1/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: %w", err)
    	}
    	defer policyClient.Close()

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

### Node.js


Before trying this sample, follow the Node.js setup instructions in the
[Data Catalog quickstart using
client libraries](https://docs.cloud.google.com/data-catalog/docs/reference/libraries).


For more information, see the
[Data Catalog Node.js API
reference documentation](https://googleapis.dev/nodejs/datacatalog/latest/index.html).


To authenticate to Data Catalog, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

    // Import the Google Cloud client library.
    const {PolicyTagManagerClient} = require('https://docs.cloud.google.com/nodejs/docs/reference/datacatalog/latest/overview.html').v1;
    const policyTagManager = new https://docs.cloud.google.com/nodejs/docs/reference/datacatalog/latest/overview.html();

    async function getTaxonomy() {
      /**
       * TODO(developer): Uncomment the following line before running the sample.
       */
      // const projectId = 'my_project'; // Google Cloud Platform project
      // const location = 'us';
      // const taxonomy = 'my_existing_taxonomy';
      // const taxonomyName = `projects/${projectId}/locations/${location}/taxonomies/${taxonomy}`;

      const request = {
        name: taxonomyName,
      };

      try {
        const [taxonomy] = await policyTagManager.getTaxonomy(request);
        console.log(`Retrieved taxonomy: ${taxonomy.name}`);
      } catch (e) {
        console.error(e);
        process.exitCode = 1;
      }
    }

## What's next


To search and filter code samples for other Google Cloud products, see the
[Google Cloud sample browser](https://docs.cloud.google.com/docs/samples?product=datacatalog).