Skip to main content

go-quickstart

Last updated on

Prerequisites

  • Ensure you have Go installed and configured on your local machine.
additional information

Depending on your environment, you may need to run additional commands. Go to the Go installation guide for more information.

  • Ensure you have access to a Harness account with the appropriate permissions to create registries and connectors.
  • Ensure you have Harness CLI installed and running in your local machine.

Create a Go Artifact Registry

private go registry

This registry will serve as your private Go registry within Harness.


Configure an Upstream Proxy (Optional)

An upstream proxy allows your registry to fetch Go modules from external sources if they are not available locally.

Create an upstream proxy


Configure the upstream proxy in your registry

upstream proxy caching

If a Go module isn’t found in your Harness registry, the upstream proxy fetches it from an external registry like proxy.golang.org, reducing duplication and improving module resolution.


Publish & Install Go modules

Authenticate the Go client

  1. In your Harness Go Artifact Registry, click Setup Client.
  2. Click Generate Token to generate an identity token.
  3. Export your token with the following command:
export GOPROXY="https://<email_address>:<TOKEN>@pkg.app.harness.io/pkg/<harness_account_id>/<go-registry-name>/go"

Publish a Go package

  • Run the following command (using Harness CLI) from your project’s root directory to publish your Go package into your Harness Registry:
hns ar push go <REGISTRY_NAME> <ARTIFACT_VERSION> --pkg-url pkg.app.harness.io

Install a Go package

  • Install your package using go get:
go get <ARTIFACT_NAME>@<VERSION>

Troubleshooting

  • Slow downloads or timeouts. Verify network egress to the Harness endpoint. If needed, configure GOPROXY explicitly and ensure your client respects it.
  • Authentication errors. Ensure your go env -w GOPRIVATE and token setup are correctly applied.
  • Package not found. Confirm the package was published to the correct Harness registry and that the version tag exists in the repository.