Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Cloud Registry
  • Getting started
    • All guides
        • Creating a Go module
        • Pulling a Go module to the registry
        • Pushing a Go module from the registry
      • Deleting an artifact from a registry
    • Creating a lifecycle policy
  • Access management
  • Pricing policy
  • Terraform reference
  • Audit Trails events

In this article:

  • Go module structure
  • Creating your Go module
  • Preparing a ZIP archive for publishing
  • What's next
  1. Step-by-step guides
  2. Managing artifacts
  3. Go artifact
  4. Creating a Go module

Creating a Go module

Written by
Yandex Cloud
Updated at July 8, 2026
View in Markdown
  • Go module structure
  • Creating your Go module
  • Preparing a ZIP archive for publishing
  • What's next

This guide describes how to create a Go module and prepare a ZIP archive for publishing to a Cloud Registry.

For more information on Go modules, see their official guides in the Go Modules Reference.

Go module structureGo module structure

Here is an example of a project structure:

mymodule/                # Go module root directory
│
├── go.mod               # Defines the Go module and its dependencies
├── go.sum               # Dependency checksums
├── main.go              # Entry point (for executable Go modules)
│
├── pkg/                 # Public packages
│   └── utils/
│       └── utils.go
│
└── internal/            # Private packages (not accessible outside the Go module)
    └── config/
        └── config.go

Creating your Go moduleCreating your Go module

  1. Install Go.

  2. Create a directory for your Go module and open it:

    mkdir mymodule && cd mymodule
    
  3. Initialize the Go module by specifying the full path under which it will be available in the registry:

    go mod init registry.yandexcloud.net/go/<registry_ID>/mymodule
    

    In the project root, a go.mod file will appear:

    module registry.yandexcloud.net/go/<registry_ID>/mymodule
    
    go 1.21
    
  4. Add your Go module code; e.g., create a file named hello.go:

    cat > hello.go << 'EOF'
    package mymodule
    
    func Hello() string {
        return "Hello from my module!"
    }
    EOF
    
  5. If you have external dependencies, synchronize go.mod and go.sum:

    go mod tidy
    

Preparing a ZIP archive for publishingPreparing a ZIP archive for publishing

The Go CLI does not support direct module publishing. To push to Cloud Registry, prepare a ZIP archive whose structure complies with Module zip files: every file inside the archive must be prefixed with a path of the <full_module_path>@<version>/ format, where <full_module_path> matches the Go module name specified in go.mod.

Warning

Maximum ZIP archive size is 500 MB.

  1. From the root of your Go module, build a ZIP archive, substituting your registry ID, module name, and version:

    find . -type f | bsdtar -a -cf ../mymodule-v1.0.0.zip \
        -s '|^\./|registry.yandexcloud.net/go/<registry_ID>/mymodule@v1.0.0/|' -T -
    

    Note

    The bsdtar utility is part of libarchive. It is preinstalled on macOS. On Debian and Ubuntu, install the libarchive-tools package:

    sudo apt install libarchive-tools
    
  2. Verify the archive structure:

    unzip -l ../mymodule-v1.0.0.zip
    

    Result:

    Archive:  ../mymodule-v1.0.0.zip
      Length      Date    Time    Name
    ---------  ---------- -----   ----
           74  2026-06-13 12:00   registry.yandexcloud.net/go/<registry_ID>/mymodule@v1.0.0/go.mod
          112  2026-06-13 12:00   registry.yandexcloud.net/go/<registry_ID>/mymodule@v1.0.0/hello.go
    ---------                     -------
          186                     2 files
    

What's nextWhat's next

  • Pulling a Go module to the registry
  • Pulling a Go module from a Cloud Registry

Was the article helpful?

Previous
Pulling a binary artifact from a registry
Next
Pulling a Go module to the registry
© 2026 Direct Cursus Technology L.L.C.