Skip to main content
The Gcore Go SDK provides convenient access to the Gcore REST API from applications written in Go. This guide will walk you through installing and configuring the SDK.

Requirements

The Gcore Go SDK requires Go 1.22 or higher. Make sure you have a compatible Go version installed:
go version

Installation

Install via go get

To install the latest version of the Gcore Go SDK, run:
go get github.com/G-Core/gcore-go

Pin to a Specific Version

For production applications, it’s recommended to pin to a specific version:
go get -u 'github.com/G-Core/[email protected]'
Replace v0.37.0 with the specific version you want to use. Check the releases page for the latest version.

Import Paths

Once installed, import the SDK in your Go code:
import (
    "github.com/G-Core/gcore-go"  // imported as gcore
)

Package Structure

The SDK is organized into service-specific packages:
import (
    "github.com/G-Core/gcore-go"
    "github.com/G-Core/gcore-go/cloud"      // Cloud services
    "github.com/G-Core/gcore-go/cdn"        // CDN services
    "github.com/G-Core/gcore-go/dns"        // DNS services
    "github.com/G-Core/gcore-go/storage"    // Storage services
    "github.com/G-Core/gcore-go/streaming"  // Streaming services
    "github.com/G-Core/gcore-go/iam"        // IAM services
    "github.com/G-Core/gcore-go/option"     // Request options
)

Environment Variables

The SDK reads configuration from environment variables by default. This makes it easy to configure your application without hardcoding credentials.

Required Variables

export GCORE_API_KEY="your-api-key"

Optional Variables

Depending on which services you’re using, you may need to set additional environment variables:
# Cloud-specific configuration
export GCORE_CLOUD_PROJECT_ID="123456"
export GCORE_CLOUD_REGION_ID="1"

# Custom API endpoint (optional)
export GCORE_BASE_URL="https://api.gcore.com"

Environment Variable Reference

VariableDescriptionRequired
GCORE_API_KEYYour Gcore API key for authenticationYes
GCORE_CLOUD_PROJECT_IDDefault Cloud project ID (for Cloud services)Optional
GCORE_CLOUD_REGION_IDDefault Cloud region ID (for Cloud services)Optional
GCORE_BASE_URLCustom API base URL (defaults to production)Optional
You can also configure these values programmatically when creating the client, which will override environment variables. See the Quickstart guide for examples.

Verifying Installation

Create a simple test file to verify your installation:
test.go
package main

import (
    "fmt"
    "github.com/G-Core/gcore-go"
    "github.com/G-Core/gcore-go/option"
)

func main() {
    client := gcore.NewClient(
        option.WithAPIKey("test-key"),
    )
    fmt.Printf("Client initialized successfully: %T\n", client)
}
Run the test:
go run test.go
If you see the output without errors, the SDK is installed correctly:
Client initialized successfully: gcore.Client

Next Steps

Quickstart

Learn how to make your first API call

Authentication

Configure API authentication

Core Concepts

Understand key SDK concepts

API Reference

Explore the full API documentation

Build docs developers (and LLMs) love