Go CLI Usage

Go CLI Usage

This page describes common CLI commands to download, resolve and publish Go modules through Sonatype Nexus Repository.

After you configure Go with Nexus, use standard Go commands to resolve, download, and verify modules through your Nexus repository.

Download a Module

After configuring Go with Nexus, run Go commands as usual from your workspace. The following command fetches the dependency through the configured Nexus endpoint.

go get <MODULE_PATH>@<VERSION>

Where,

Example:

go get github.com/user_account/module@v1.0.0

Resolve Dependencies

Use go mod tidy to resolve the full transitive dependency graph and update module metadata.

When your client is configured to use Nexus, transitive dependencies are also resolved through the configured Go repository.

Upload a Module

Use the REST API to upload modules to a Nexus hosted repository.

curl -u <USERNAME>:<PASSWORD> \
  -X PUT \
  "https://<NEXUS_URL>/repository/<REPOSITORY_NAME>/<VERSION>.zip" \
  --upload-file <MODULE_ARCHIVE>.zip

Where,

Example:

curl -u admin:admin123 \
  -X PUT \
  "https://example.nexus.com/repository/go-hosted/v1.2.3.zip" \
  --upload-file mymodule@v1.2.3.zip

Search results

No results found