[Yandex Cloud documentation](../../../index.md) > [Yandex Cloud Registry](../../index.md) > [Step-by-step guides](../index.md) > Managing artifacts > Go artifact > Pulling a Go module to the registry

# Pulling a Go module to the registry

Before pushing, prepare a ZIP archive of your Go module. For more information, see [Creating a Go module](create.md).

1. Create the following environment variables depending on the authentication method:
   
   {% list tabs group=registry_auth %}
   
   - IAM token {#iam-token}
   
     1. Get an [IAM token](../../../iam/concepts/authorization/iam-token.md) for the [Yandex account](../../../iam/operations/iam-token/create.md) or [service account](../../../iam/operations/iam-token/create-for-sa.md) you are going to use for authentication.
     1. Create the `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` environment variables:
   
         ```bash
         export REGISTRY_USERNAME="iam"
         export REGISTRY_PASSWORD="<IAM_token>"
         ```
   
         Where:
   
         * `REGISTRY_USERNAME`: Authentication method.
         * `REGISTRY_PASSWORD`: Body of the previously obtained IAM token.
   
     {% note info %}
   
     The IAM token's [lifetime](../../../iam/concepts/authorization/iam-token.md#lifetime) is limited to 12 hours.
   
     {% endnote %}
   
   - API key {#api-key}
   
     1. [Create](../../../iam/operations/authentication/manage-api-keys.md#create-api-key) an API key for the [service account](../../../iam/concepts/users/service-accounts.md) you are going to use for authentication.
     1. Create the `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` environment variables:
   
         ```bash
         export REGISTRY_USERNAME="api_key"
         export REGISTRY_PASSWORD="<API_key>"
         ```
   
         Where:
   
         * `REGISTRY_USERNAME`: Authentication method.
         * `REGISTRY_PASSWORD`: Body of the previously created [API key](../../../iam/concepts/authorization/api-key.md).
   
     {% note info %}
   
     The API key maximum [lifetime](../../../iam/concepts/authorization/api-key.md#scoped-api-keys) is set manually when you create the key.
   
     {% endnote %}
   
   {% endlist %}
1. Push the [Go module](../../concepts/artifacts/go.md) using a PUT HTTP request:

    ```bash
    curl \
      --request PUT \
      --user "$REGISTRY_USERNAME:$REGISTRY_PASSWORD" \
      --header "X-Checksum-SHA256: <file_hash>" \
      --upload-file <local_path_to_ZIP_file> \
      https://registry.yandexcloud.net/go/<registry_ID>/<module_name>/<module_version>/<file_name_in_registry>
    ```

    Where:

    * `--request`: Method.
    * `--user`: Authentication data.
    * `--header`: API request header. This is an optional setting.

        In the `X-Checksum-SHA256` header, you can specify the hash of the file you are pushing to check the file’s integrity after it is pushed. You can generate the hash, e.g., using this command:

        ```bash
        openssl dgst -sha256 <file_path> | awk '{print $2}'
        ```

    * `--upload-file`: Local path to the ZIP file. 
    * The request URL contains the registry URL, the Go module name and version, and the file name in the registry. For example:

        ```bash
        https://registry.yandexcloud.net/go/cn15fqbr806r********/mymodule/1.0.0/mymodule-v1.0.0.zip
        ```

    {% note warning %}

    In the URL, provide the Go module version without the `v` prefix; e.g., for version `v1.0.0`, specify `1.0.0`.

    {% endnote %}

    {% note warning %}

    When publishing a Go module, do not prefix its name with `registry.yandexcloud.net/go/<registry_ID>/`. If your Go module's major version is greater than 1, omit the `/vN` suffix as well; e.g., for a `registry.yandexcloud.net/go/<registry_ID>/sample/module/v4` Go module, use `sample/module` as its name.

    {% endnote %}