Help us shape the future of Go! Take the 2026 Go Developer Survey

licensing

package module
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 12 Imported by: 0

README

Digitea Licensing Go SDK

Official Go client for the Digitea Runtime Licensing API.

The public licensing.Client facade is in the root package. The OpenAPI transport under generated/ is an implementation detail.

Installation

go get github.com/getdigitea/Digitea-go@v1.2.3

Quick start

import (
    "context"
    "time"
    licensing "github.com/getdigitea/Digitea-go"
)

client, err := licensing.NewClient(
    "prd_example123",
    "https://api.getdigitea.com",
    "stable-installation-id",
    nil,
    10*time.Second,
    2,
)
if err != nil { panic(err) }

activation, err := client.Activate(
    context.Background(),
    "dgt_lic_example",
    "",
)
if err != nil { panic(err) }

if activation.GetValid() && activation.GetStatus() == "ACTIVE" {
    startApplication()
}

Complete lifecycle

validation, err := client.Validate(ctx, licenseKey, "")
if err != nil { handleLicensingError(err) }

if validation.GetValid() && validation.GetStatus() == "ACTIVE" {
    enableLicensedFeatures()
}

deactivation, err := client.Deactivate(ctx, licenseKey, "")

Renewal session and idempotency

renewal, err := client.CreateRenewalSessionWithReturnURL(
    ctx,
    licenseKey,
    "",
    "renewal-operation-123",
    "https://software.example.com/license-renewal",
)
if err != nil { handleLicensingError(err) }
openInBrowser(renewal.GetCheckoutUrl())

// Run after the browser returns; the redirect is not proof of payment.
renewalStatus, err := client.GetRenewalSessionStatus(ctx, licenseKey, "", renewal.GetRenewalSessionId())
if err != nil { handleLicensingError(err) }
if renewalStatus.GetStatus() == "PAID" {
    validation, err = client.Validate(ctx, licenseKey, "")
}

The Go SDK supports creating a renewal session with CreateRenewalSessionWithReturnURL and reading its status with GetRenewalSessionStatus.

Reuse the same fourth argument, idempotencyKey, when retrying the same logical renewal operation. If empty, the SDK generates a valid key and reuses it across HTTP retries.

Configuration, identity and errors

When instanceID is empty, the client loads or creates a persistent installation identity through the supplied InstanceIDStore.

var digiteaError *licensing.DigiteaError
if errors.As(err, &digiteaError) {
    switch digiteaError.Code {
    case "LICENSE_EXPIRED":
        showRenewalScreen()
    case "NETWORK_ERROR", "TEMPORARILY_UNAVAILABLE":
        showTemporaryConnectionError()
    }
}

Runtime calls use only product, license and installation identifiers. Temporary network, rate-limit and server failures are retried.

Security

Never embed a Developer API key, webhook secret or server credential in distributed Go software. Never log a license key. Use HTTPS in production.

The same five operations are available in every Runtime SDK:

  • Activate()
  • Validate()
  • Deactivate()
  • CreateRenewalSession()
  • GetRenewalSessionStatus()

Repository: https://github.com/getdigitea/Digitea-go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(productID, baseURL, instanceID string, store InstanceIDStore, timeout time.Duration, retries int) (*Client, error)

func (*Client) Activate

func (c *Client) Activate(ctx context.Context, licenseKey, instanceID string) (*generated.ActivationResult, error)

func (*Client) CreateRenewalSession

func (c *Client) CreateRenewalSession(ctx context.Context, licenseKey, instanceID, idempotencyKey string) (*generated.RenewalSessionResult, error)

func (*Client) CreateRenewalSessionWithReturnURL

func (c *Client) CreateRenewalSessionWithReturnURL(ctx context.Context, licenseKey, instanceID, idempotencyKey, returnURL string) (*generated.RenewalSessionResult, error)

func (*Client) Deactivate

func (c *Client) Deactivate(ctx context.Context, licenseKey, instanceID string) (*generated.DeactivationResult, error)

func (*Client) GetRenewalSessionStatus

func (c *Client) GetRenewalSessionStatus(ctx context.Context, licenseKey, instanceID, renewalSessionID string) (*generated.RenewalStatusResult, error)

func (*Client) Validate

func (c *Client) Validate(ctx context.Context, licenseKey, instanceID string) (*generated.ValidationResult, error)

type DigiteaError

type DigiteaError struct {
	Code       string
	Status     int
	Details    any
	RetryAfter time.Duration
}

func (*DigiteaError) Error

func (e *DigiteaError) Error() string

type FileInstanceIDStore

type FileInstanceIDStore struct{ Path string }

func (FileInstanceIDStore) Load

func (s FileInstanceIDStore) Load() (string, error)

func (FileInstanceIDStore) Save

func (s FileInstanceIDStore) Save(value string) error

type InstanceIDStore

type InstanceIDStore interface {
	Load() (string, error)
	Save(string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL