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,
<MODULE_PATH>- The module path of the Go package<VERSION>- The module version
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,
<USERNAME>- Your Nexus username or user token name code<PASSWORD>- Your Nexus password or user token pass code<NEXUS_URL>- Your Nexus instance URL<REPOSITORY_NAME>- Your Nexus hosted repository name<VERSION>- The module version
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