Skip to content

deepgram/deepgram-go-sdk

Repository files navigation

Deepgram Go SDK

Discord Go Reference Contributor Covenant

Official Go SDK for Deepgram. Power your apps with world-class speech and Language AI models.

Documentation

You can learn more about the Deepgram API at developers.deepgram.com.

Documentation for specifics about the structs, interfaces, and functions of this SDK can be found here: Go SDK Documentation

Migrating from earlier versions

V1.2 to V1.3

See the migration guide for more details.

V1 to V2

The Voice Agent interfaces have been updated to use the new Voice Agent V1 API. Please refer to our Documentation on Migration to new V1 Agent API.

V2.* to V3

V3 Introduced a generic object approach for Agent Providers to ease the maintenance overhead of adding new providers see this PR for more details.

Requirements

Go (version ^1.19)

Installation

To incorporate this SDK into your project's go.mod file, run the following command from your repo:

go get github.com/deepgram/deepgram-go-sdk/v3

Getting an API Key

🔑 To access the Deepgram API you will need a free Deepgram API Key.

Initialization

All of the examples below will require initializing the Deepgram client and inclusion of imports. The SDK supports dual authentication with both API Keys and Bearer tokens.

package main

import (
    "context"
    "fmt"
    "log"
    "os"

    api "github.com/deepgram/deepgram-go-sdk/v3/pkg/api/listen/v1/rest"
    interfaces "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/interfaces/v1"
    client "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/listen"
)

ctx := context.Background()

// Option 1: API Key Authentication (Traditional)
c := client.NewREST("YOUR_API_KEY", &interfaces.ClientOptions{
    Host: "https://api.deepgram.com",
})

// Option 2: Bearer Token Authentication (Modern)
c := client.NewREST("", &interfaces.ClientOptions{
    Host:        "https://api.deepgram.com",
    AccessToken: "YOUR_ACCESS_TOKEN",
})

// Option 3: Environment Variables (Recommended)
// Set DEEPGRAM_API_KEY or DEEPGRAM_ACCESS_TOKEN
c := client.NewWithDefaults()

Pre-Recorded (Synchronous)

Remote Files (Synchronous)

Transcribe audio from a URL.

// Define Deepgram options
options := &interfaces.PreRecordedTranscriptionOptions{
    Model:       "nova-3",
}
// Define url to use
URL := "https://dpgr.am/spacewalk.wav"
res, err := dg.FromURL(ctx, URL, options)
if err != nil {
    log.Fatalf("FromURL failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Transcript: %s\n", res.Results.Channels[0].Alternatives[0].Transcript)

See our API reference for more info.

Local Files (Synchronous)

Transcribe audio from a file.

// Define Deepgram options
options := &interfaces.PreRecordedTranscriptionOptions{
    Model:       "nova-3",
}
// Define file to use
filePath := "path/to/your/audio.wav"
res, err := dg.FromFile(ctx, filePath, options)
if err != nil {
    log.Fatalf("FromFile failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Transcript: %s\n", res.Results.Channels[0].Alternatives[0].Transcript)

See our API reference for more info.

Pre-Recorded (Asynchronous / Callbacks)

Remote Files (Asynchronous)

Transcribe audio from a URL with callback.

// Define Deepgram options
options := &interfaces.PreRecordedTranscriptionOptions{
    Model:       "nova-3",
}
// Define URL to use
URL := "https://dpgr.am/spacewalk.wav"
callbackURL := "https://your-callback-url.com/webhook"
res, err := dg.FromURLAsync(ctx, URL, callbackURL, options)
if err != nil {
    log.Fatalf("FromURLAsync failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Request ID: %s\n", res.RequestID)

See our API reference for more info.

Local Files (Asynchronous)

Transcribe audio from a file with callback.

// Define Deepgram options
options := &interfaces.PreRecordedTranscriptionOptions{
    Model:       "nova-3",
}
// Define file to use and Callback URL
filePath := "path/to/your/audio.wav"
callbackURL := "https://your-callback-url.com/webhook"
res, err := dg.FromFileAsync(ctx, filePath, callbackURL, options)
if err != nil {
    log.Fatalf("FromFileAsync failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Request ID: %s\n", res.RequestID)

See our API reference for more info.

Streaming Audio

Transcribe streaming audio.

import (
    "context"
    "fmt"
    "os"

    interfaces "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/interfaces"
    client "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/listen"
)

// Initiate Client
client.InitWithDefault()
ctx := context.Background()

// Create WebSocket client with default handler
dgClient, err := client.NewWSUsingChanForDemo(ctx, &interfaces.LiveTranscriptionOptions{})
// Define Deepgram options
options := &interfaces.LiveTranscriptionOptions{
    Model:     "nova-3",
}

// Define Streaming URL
const audioURL = "streaming_audio.url"

// Connect to Deepgram WebSocket
dgClient.Connect()

// Fetch audio from URL
resp, err := http.Get(audioURL)
if err != nil {
    fmt.Printf("Error fetching audio: %v\n", err)
    os.Exit(1)
}
defer resp.Body.Close()

// Stream audio data to Deepgram in background
go dgClient.Stream(bufio.NewReader(resp.Body))

// Wait for user input to exit
fmt.Println("Press ENTER to exit...")
bufio.NewScanner(os.Stdin).Scan()

// Cleanup and close connection
dgClient.Stop()

See our API reference for more info.

Voice Agent

Configure a Voice Agent using WebSocket.

import (
    "context"
    "fmt"
    "os"
    "time"

    interfaces "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/interfaces"
    client "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/agent"
)

// Initialize the SDK
client.InitWithDefault()

// Create context
ctx := context.Background()

// Configure agent settings
options := &interfaces.SettingsOptions{}
options.Language = "en"
options.Agent.Think.Provider.Type = "open_ai"
options.Agent.Think.Provider.Model = "gpt-4o-mini"
options.Agent.Think.Prompt = "You are a helpful AI assistant."
options.Agent.Listen.Provider.Type = "deepgram"
options.Agent.Listen.Provider.Model = "nova-3"
options.Agent.Speak.Provider.Type = "deepgram"
options.Agent.Speak.Provider.Model = "aura-2-thalia-en"
options.Greeting = "Hello, I'm your AI assistant."

// Create Deepgram client (uses default handler that prints to console)
dgClient, err := client.NewWSUsingChanForDemo(ctx, options)
if err != nil {
    fmt.Printf("Error creating client: %v\n", err)
    os.Exit(1)
}

// Connect to Deepgram
dgClient.Connect()

// Keep connection alive
time.Sleep(30 * time.Second)

// Cleanup
dgClient.Stop()

This example demonstrates:

  • Setting up a WebSocket connection for Voice Agent
  • Configuring the agent with speech, language, and audio settings
  • Handling various agent events (speech, transcripts, audio)
  • Sending audio data and keeping the connection alive

For a complete implementation, you would need to:

  1. Add your audio input source (e.g., microphone)
  2. Implement audio playback for the agent's responses
  3. Handle any function calls if your agent uses them
  4. Add proper error handling and connection management

See our API reference for more info.

Text to Speech REST

Convert text into speech using the REST API.

// Define Deepgram options
options := &interfaces.SpeakOptions{
    Model:      "aura-2-thalia-en",
}

// Convert text to speech and save to file
text := "Hello world!"
filePath := "output.wav"
res, err := dg.ToSave(ctx, filePath, text, options)
if err != nil {
    fmt.Printf("ToSave failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Audio saved to: %s\n", filePath)

See our API reference for more info.

Text to Speech Streaming

Convert streaming text into speech using a WebSocket.

// Define Deepgram options
options := &interfaces.SpeakWSOptions{
    Model:      "aura-2-thalia-en",
    Encoding:   "linear16",
    SampleRate: 16000,
}

// Create Deepgram client with custom callback
dgClient, err := client.NewWSUsingCallback(ctx, "", &interfaces.ClientOptions{}, options, callback)
    if err != nil {
    fmt.Printf("Error creating client: %v\n", err)
        os.Exit(1)
    }

    // Connect to Deepgram
dgClient.Connect()

// Send text to convert to speech
text := "Hello, this is a text to speech example."
dgClient.SendText(text)
dgClient.Flush()

// Wait for completion and cleanup
dgClient.WaitForComplete()
dgClient.Stop()

See our API reference for more info.

Text Intelligence

Analyze text.

// Define Deepgram options
options := &interfaces.AnalyzeOptions{
    Model: "Nova-3"
    // Read options
}

// Define text file to analyze
filePath := "text_to_analyze.txt"

// Analyze text content from file
res, err := dg.FromFile(ctx, filePath, options)
if err != nil {
    fmt.Printf("FromFile failed. Err: %v\n", err)
    os.Exit(1)
}

// Display results
fmt.Printf("Analysis Results: %+v\n", res.Results)

See our API reference for more info.

Authentication

The Deepgram Go SDK supports dual authentication with both traditional API Keys and modern JWT Bearer tokens. This provides flexibility for different authentication workflows while maintaining 100% backward compatibility.

Authentication Methods

1. API Key Authentication (Traditional)

Use your Deepgram API Key directly:

// Using API key in client options
c := client.NewREST("YOUR_API_KEY", &interfaces.ClientOptions{
    Host: "https://api.deepgram.com",
})

// Or using environment variable
// Set DEEPGRAM_API_KEY=your_api_key
c := client.NewWithDefaults()

2. Bearer Token Authentication (Modern)

Use JWT Bearer tokens for enhanced security:

// Using Bearer token in client options
c := client.NewREST("", &interfaces.ClientOptions{
    Host:        "https://api.deepgram.com",
    AccessToken: "YOUR_ACCESS_TOKEN",
})

// Or using environment variable
// Set DEEPGRAM_ACCESS_TOKEN=your_access_token
c := client.NewWithDefaults()

3. Dynamic Authentication Switching

Switch between authentication methods at runtime:

// Initialize client
c := client.NewREST("YOUR_API_KEY", &interfaces.ClientOptions{
    Host: "https://api.deepgram.com",
})

// Switch to Bearer token authentication
c.SetAccessToken("YOUR_ACCESS_TOKEN")

// Switch back to API key authentication
c.SetAPIKey("YOUR_API_KEY")

// Get current effective authentication
token, isBearer := c.GetAuthToken()
if isBearer {
    fmt.Printf("Using Bearer token: %s\n", token)
} else {
    fmt.Printf("Using API key: %s\n", token)
}

Authentication Priority

When multiple authentication methods are provided, the SDK uses the following priority order:

  1. Explicit AccessToken parameter (highest priority)
  2. Explicit APIKey parameter
  3. DEEPGRAM_ACCESS_TOKEN environment variable
  4. DEEPGRAM_API_KEY environment variable (lowest priority)
// Example: AccessToken takes precedence over APIKey
c := client.NewREST("fallback_api_key", &interfaces.ClientOptions{
    AccessToken: "preferred_access_token", // This will be used
    Host:        "https://api.deepgram.com",
})

Environment Variables

Set your credentials using environment variables:

# API Key authentication
export DEEPGRAM_API_KEY="your_api_key"

# Bearer token authentication (takes precedence if both are set)
export DEEPGRAM_ACCESS_TOKEN="your_access_token"

# Optional: Custom host
export DEEPGRAM_HOST="https://api.deepgram.com"

Then initialize the client without explicit credentials:

// Automatically uses environment variables based on priority
c := client.NewWithDefaults()

OAuth-Style Workflow: API Key → Bearer Token

The SDK supports a complete OAuth-style authentication workflow where you use an API key to obtain a Bearer token, then use that token for subsequent requests:

import (
    "context"

    authAPI "github.com/deepgram/deepgram-go-sdk/v3/pkg/api/auth/v1"
    authClient "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/auth"
    interfaces "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/interfaces/v1"
    listenClient "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/listen"
)

func main() {
    ctx := context.Background()

    // Step 1: Use API Key to get Bearer token
    authOptions := &interfaces.ClientOptions{
        APIKey: "YOUR_API_KEY",
    }

    authClient := authClient.NewWithOptions(authOptions)
    tokenResponse, err := authClient.GrantToken(ctx, &authAPI.GrantTokenRequest{})
    if err != nil {
        log.Fatal("Failed to get token:", err)
    }

    // Step 2: Use Bearer token for API calls
    clientOptions := &interfaces.ClientOptions{
        AccessToken: tokenResponse.AccessToken, // Bearer token
    }

    listenClient := listenClient.NewRESTWithOptions(clientOptions)

    // Step 3: Make API calls with Bearer authentication
    result, err := listenClient.FromURL(ctx, "https://dpgr.am/spacewalk.wav", &interfaces.PreRecordedTranscriptionOptions{
        Model: "nova-3",
    })
    if err != nil {
        log.Fatal("Transcription failed:", err)
    }

    fmt.Printf("Transcript: %s\n", result.Results.Channels[0].Alternatives[0].Transcript)
}

Grant Token

Creates a temporary token with a 30-second TTL using your API key:

// Grant token using API key
res, err := dg.GrantToken(ctx)
if err != nil {
    fmt.Printf("GrantToken failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Access Token: %s\n", res.AccessToken)
fmt.Printf("Expires In: %d seconds\n", res.ExpiresIn)

The generated token can then be used for Bearer authentication:

// Use the granted token for Bearer authentication
clientOptions := &interfaces.ClientOptions{
    AccessToken: res.AccessToken,
}
dgClient := client.NewRESTWithOptions(clientOptions)

Migration Guide

Existing code continues to work unchanged! No migration is required for current implementations.

To adopt Bearer tokens:

// Old way (still works)
c := client.NewREST("YOUR_API_KEY", &interfaces.ClientOptions{})

// New way with Bearer token
c := client.NewREST("", &interfaces.ClientOptions{
    AccessToken: "YOUR_ACCESS_TOKEN",
})

// Best practice: Use environment variables
// Set DEEPGRAM_ACCESS_TOKEN or DEEPGRAM_API_KEY
c := client.NewWithDefaults()

See our API reference for more info.

Projects

Get Projects

Returns all projects accessible by the API key.

// Get all projects
res, err := dg.ListProjects(ctx)
if err != nil {
    fmt.Printf("ListProjects failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Projects: %+v\n", res.Projects)

See our API reference for more info.

Get Project

Retrieves a specific project based on the provided project_id.

// Get specific project
res, err := dg.GetProject(ctx, myProjectId)
if err != nil {
    fmt.Printf("GetProject failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Project: %+v\n", res.Project)

See our API reference for more info.

Update Project

Update a project.

// Update project
options := &interfaces.ProjectUpdateRequest{
    Name: "Updated Project Name",
}
res, err := dg.UpdateProject(ctx, myProjectId, options)
if err != nil {
    fmt.Printf("UpdateProject failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Update result: %s\n", res.Message)

See our API reference for more info.

Delete Project

Delete a project.

// Delete project
res, err := dg.DeleteProject(ctx, myProjectId)
if err != nil {
    fmt.Printf("DeleteProject failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Delete result: %s\n", res.Message)

See our API reference for more info.

Keys

List Keys

Retrieves all keys associated with the provided project_id.

// List all keys
res, err := dg.ListKeys(ctx, myProjectId)
if err != nil {
    fmt.Printf("ListKeys failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Keys: %+v\n", res.APIKeys)

See our API reference for more info

Get Key

Retrieves a specific key associated with the provided project_id.

// Get specific key
res, err := dg.GetKey(ctx, myProjectId, myKeyId)
if err != nil {
    fmt.Printf("GetKey failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Key: %+v\n", res.APIKey)

See our API reference for more info

Create Key

Creates an API key with the provided scopes.

// Create new key
options := &interfaces.KeyCreateRequest{
    Comment: "My API Key",
    Scopes:  []string{"admin"},
}
res, err := dg.CreateKey(ctx, myProjectId, options)
if err != nil {
    fmt.Printf("CreateKey failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Created key: %s\n", res.APIKeyID)

See our API reference for more info

Delete Key

Deletes a specific key associated with the provided project_id.

// Delete key
res, err := dg.DeleteKey(ctx, myProjectId, myKeyId)
if err != nil {
    fmt.Printf("DeleteKey failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Delete result: %s\n", res.Message)

See our API reference for more info

Members

Get Members

Retrieves account objects for all of the accounts in the specified project_id.

// List all members
res, err := dg.ListMembers(ctx, myProjectId)
if err != nil {
    fmt.Printf("ListMembers failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Members: %+v\n", res.Members)

See our API reference for more info.

Remove Member

Removes member account for specified member_id.

// Remove member
res, err := dg.RemoveMember(ctx, myProjectId, memberId)
    if err != nil {
    fmt.Printf("RemoveMember failed. Err: %v\n", err)
        os.Exit(1)
    }

fmt.Printf("Remove result: %s\n", res.Message)

See our API reference for more info.

Scopes

Get Member Scopes

Retrieves scopes of the specified member in the specified project.

// Get member scopes
res, err := dg.GetMemberScopes(ctx, myProjectId, memberId)
if err != nil {
    fmt.Printf("GetMemberScopes failed. Err: %v\n", err)
        os.Exit(1)
    }

fmt.Printf("Scopes: %+v\n", res.Scopes)

See our API reference for more info.

Update Scope

Updates the scope for the specified member in the specified project.

// Update member scope
options := &interfaces.ScopeUpdateRequest{
    Scope: "admin",
}
res, err := dg.UpdateMemberScopes(ctx, myProjectId, memberId, options)
if err != nil {
    fmt.Printf("UpdateMemberScopes failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Update result: %s\n", res.Message)

See our API reference for more info.

Invitations

List Invites

Retrieves all invitations associated with the provided project_id.

// List all invitations
res, err := dg.ListInvitations(ctx, myProjectId)
if err != nil {
    fmt.Printf("ListInvitations failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Invitations: %+v\n", res.Invites)

See our API reference for more info.

Send Invite

Sends an invitation to the provided email address.

// Send invitation
options := &interfaces.InvitationCreateRequest{
    Email: "[email protected]",
    Scope: "admin",
}
res, err := dg.SendInvitation(ctx, myProjectId, options)
if err != nil {
    fmt.Printf("SendInvitation failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Invitation sent: %s\n", res.Message)

See our API reference for more info.

Delete Invite

Removes the specified invitation from the project.

// Delete invitation
res, err := dg.DeleteInvitation(ctx, myProjectId, email)
if err != nil {
    fmt.Printf("DeleteInvitation failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Delete result: %s\n", res.Message)

See our API reference for more info.

Leave Project

// Leave project
res, err := dg.LeaveProject(ctx, myProjectId)
if err != nil {
    fmt.Printf("LeaveProject failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Leave result: %s\n", res.Message)

See our API reference for more info.

Usage

Get All Requests

Retrieves all requests associated with the provided project_id based on the provided options.

// Get all requests
res, err := dg.GetUsageRequests(ctx, myProjectId)
if err != nil {
    fmt.Printf("GetUsageRequests failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Requests: %+v\n", res.Requests)

See our API reference for more info.

Get Request

Retrieves a specific request associated with the provided project_id

// Get specific request
res, err := dg.GetUsageRequest(ctx, myProjectId, requestId)
if err != nil {
    fmt.Printf("GetUsageRequest failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Request: %+v\n", res.Request)

See our API reference for more info.

Get Fields

Lists the features, models, tags, languages, and processing method used for requests in the specified project.

// Get usage fields
res, err := dg.GetUsageFields(ctx, myProjectId)
if err != nil {
    fmt.Printf("GetUsageFields failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Fields: %+v\n", res.Fields)

See our API reference for more info.

Summarize Usage

Deprecated Retrieves the usage for a specific project. Use Get Project Usage Breakdown for a more comprehensive usage summary.

// Get usage summary
res, err := dg.GetUsageSummary(ctx, myProjectId)
if err != nil {
    fmt.Printf("GetUsageSummary failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Usage summary: %+v\n", res.Usage)

See our API reference for more info.

Billing

Get All Balances

Retrieves the list of balance info for the specified project.

// Get all balances
res, err := dg.GetBalances(ctx, myProjectId)
if err != nil {
    fmt.Printf("GetBalances failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Balances: %+v\n", res.Balances)

See our API reference for more info.

Get Balance

Retrieves the balance info for the specified project and balance_id.

// Get specific balance
res, err := dg.GetBalance(ctx, myProjectId, balanceId)
if err != nil {
    fmt.Printf("GetBalance failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Balance: %+v\n", res.Balance)

See our API reference for more info.

Models

Get All Project Models

Retrieves all models available for a given project.

// Get all project models
res, err := dg.GetProjectModels(ctx, myProjectId)
if err != nil {
    fmt.Printf("GetProjectModels failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Models: %+v\n", res)

See our API reference for more info.

Get Model

Retrieves details of a specific model.

// Get specific model
res, err := dg.GetProjectModel(ctx, myProjectId, modelId)
    if err != nil {
    fmt.Printf("GetProjectModel failed. Err: %v\n", err)
        os.Exit(1)
    }

fmt.Printf("Model: %+v\n", res.Model)

See our API reference for more info.

On-Prem APIs

List On-Prem credentials

Lists sets of distribution credentials for the specified project.

// List on-prem credentials
res, err := dg.ListSelfhostedCredentials(ctx, projectId)
if err != nil {
    fmt.Printf("ListSelfhostedCredentials failed. Err: %v\n", err)
        os.Exit(1)
    }

fmt.Printf("Credentials: %+v\n", res.Credentials)

See our API reference for more info.

Get On-Prem credentials

Returns a set of distribution credentials for the specified project.

// Get specific on-prem credentials
res, err := dg.GetSelfhostedCredentials(ctx, projectId, distributionCredentialsId)
if err != nil {
    fmt.Printf("GetSelfhostedCredentials failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Credentials: %+v\n", res.Credentials)

See our API reference for more info.

Create On-Prem credentials

Creates a set of distribution credentials for the specified project.

// Create on-prem credentials
options := &interfaces.SelfhostedCredentialsCreateRequest{
    Comment: "My on-prem credentials",
}
res, err := dg.CreateSelfhostedCredentials(ctx, projectId, options)
if err != nil {
    fmt.Printf("CreateSelfhostedCredentials failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Created credentials: %s\n", res.CredentialsID)

See our API reference for more info.

Delete On-Prem credentials

Deletes a set of distribution credentials for the specified project.

// Delete on-prem credentials
res, err := dg.DeleteSelfhostedCredentials(ctx, projectId, distributionCredentialId)
if err != nil {
    fmt.Printf("DeleteSelfhostedCredentials failed. Err: %v\n", err)
    os.Exit(1)
}

fmt.Printf("Delete result: %s\n", res.Message)

See our API reference for more info.

Logging

This SDK provides logging as a means to troubleshoot and debug issues encountered. By default, this SDK will enable Information level messages and higher (ie Warning, Error, etc) when you initialize the library as follows:

client.InitWithDefault();

To increase the logging output/verbosity for debug or troubleshooting purposes, you can set the TRACE level but using this code:

// init library
client.Init(client.InitLib{
    LogLevel: client.LogLevelTrace,
})

Testing

There are several test folders in /tests you can run:

  • unit_test/ - Unit tests
  • daily_test/ - Integration/daily tests
  • edge_cases/ - Edge case testing
  • response_data/ - Test data
  • utils/ - Test utilities

To run the tests, you can use the following commands:

Run specific tests in a directory:

go run filename

Backwards Compatibility

We follow semantic versioning (semver) to ensure a smooth upgrade experience. Within a major version (like 3.*), we will maintain backward compatibility so your code will continue to work without breaking changes. When we release a new major version (like moving from 2.* to 3.*), we may introduce breaking changes to improve the SDK. We'll always document these changes clearly in our release notes to help you upgrade smoothly.

Older SDK versions will receive Priority 1 (P1) bug support only. Security issues, both in our code and dependencies, are promptly addressed. Significant bugs without clear workarounds are also given priority attention.

Development and Contributing

Interested in contributing? We ❤️ pull requests!

To make sure our community is safe for all, be sure to review and agree to our Code of Conduct. Then see the Contribution guidelines for more information.

Getting Help

We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either: