# Scan Go packages manually

This quickstart shows you how to pull a container image, manually scan it with
On-Demand Scanning, and retrieve identified vulnerabilities for system and Go
packages. To follow this quickstart you will use Cloud Shell and an example
Alpine image.

## Before you begin

## Download and scan an image

1. Open a Cloud Shell in your project.

   [Open Cloud Shell](https://console.cloud.google.com/?cloudshell=true)

   This opens a terminal with all the required tools to follow this guide.
2. Use docker to pull the container image:

       docker pull golang:1.17.6-alpine

3. Run the scan:

       gcloud artifacts docker images scan golang:1.17.6-alpine --additional-package-types=GO

   This triggers that scanning process and returns the scan name when finished:

   ```
   ✓ Scanning container image
     ✓ Locally extracting packages and versions from local container image
     ✓ Remotely initiating analysis of packages and versions
     ✓ Waiting for analysis operation to complete [projects/my-project/locations/us/operations/849db1f8-2fb2-4559-9fe0-8720d8cd347c]
   Done.
   done: true
   metadata:
     '@type': type.googleapis.com/google.cloud.ondemandscanning.v1.AnalyzePackagesMetadata
     createTime: '2022-01-11T16:58:11.711487Z'
     resourceUri: golang:1.16.13-alpine
   name: projects/my-project/locations/us/operations/f4adb1f8-20b2-4579-9fe0-8720d8cd347c
   response:
     '@type': type.googleapis.com/google.cloud.ondemandscanning.v1.AnalyzePackagesResponse
     scan: projects/my-project/locations/us/scans/a54f12b0-ca2d-4d93-8da5-5cf48e9e20ef
   ```
4. Use the scan name, the value of `scan` from the output, to fetch the scan results:

       gcloud artifacts docker images list-vulnerabilities \
       projects/my-project/locations/us/scans/a54f12b0-ca2d-4d93-8da5-5cf48e9e20ef

   The output contains a list of Go, Go standard library, and Linux package
   vulnerabilities. The following labels indicate the type of Go
   vulnerabilities:
   - `packageType:GO_STDLIB`. Go standard library vulnerabilities. This indicates
     that the vulnerability was found either in the Go toolchain used to build
     the binary, or in the standard library bundled with the toolchain. A possible
     fix is to upgrade your build toolchain.

   - `packageType:GO`. Go package vulnerabilities. This indicates that the
     vulnerability was found in a third-party package. A possible fix is to
     upgrade your dependent modules.

## Clean up


To avoid incurring charges to your Google Cloud account for
the resources used on this page, follow these steps.

> [!CAUTION]
> **Caution** : Deleting a project has the following effects:
>
> - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.
> - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.
>
>
> If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects
> can help you avoid exceeding project quota limits.

1. In the Google Cloud console, go to the **Manage resources** page.

   [Go to Manage resources](https://console.cloud.google.com/iam-admin/projects)
2. In the project list, select the project that you want to delete, and then click **Delete**.
3. In the dialog, type the project ID, and then click **Shut down** to delete the project.

## What's next

- [Explore all the Go package scanning options](https://docs.cloud.google.com/artifact-analysis/docs/scan-go-on-demand).
- [Understand container scanning concepts](https://docs.cloud.google.com/artifact-analysis/docs/container-scanning-overview).