Skip to content
LICENTIVO / INTEGRATION

Add software licensing to a Go application

Install the Go SDK, activate with a customer's key and protect a real file export. The SDK manages device identity, signed authorization, saved credentials and heartbeats.

About 15 minutes with Go installedUpdated

1. Prepare a product and license

Use this path for a desktop utility, command-line application or a service that needs a node-locked license. Start with an unmetered export feature so you can verify licensing before adding usage counters.

  1. Install Go 1.26 or later. In the console, open Quick integration and create a product.
  2. Enable a feature named export in the product's authorization policy. Create or select a test license.
  3. Download the configured Go integration package. Keep product.json for public product settings; sdk-demo.json contains a private test key and must stay out of customer builds.

2. Install the SDK into your project

Open SDK documentation, select Go and your operating system, then run the website's versioned installation command from your project directory. Use the generated local module dependency. The import path is github.com/spf86/licentivo-sdk; the installer supplies that module locally, so this example does not require a GitHub release.

Keep the installed version fixed while integrating. Verify it with go list -m github.com/spf86/licentivo-sdk. Copy your product.json to the application's working directory.

For a new project use the commands below; in an existing project omit go mod init. Keep your own product.json from the console. After saving main.go from the next section, set LICENTIVO_LICENSE_KEY and run go run .

Windows · PowerShell
go mod init example.com/licensed-app
Invoke-WebRequest 'https://www.licentivo.com/assets/sdk/releases/v0.10.0/install.ps1' -OutFile install-licentivo.ps1
./install-licentivo.ps1 -Language go -Version 0.10.0
Linux / macOS · Bash
go mod init example.com/licensed-app
curl --fail --location --proto '=https' --proto-redir '=https' --tlsv1.2 \
  -o install-licentivo.sh \
  'https://www.licentivo.com/assets/sdk/releases/v0.10.0/install.sh'
bash install-licentivo.sh go --version 0.10.0

3. Protect one operation

Save this program as main.go. Supply a test key through LICENTIVO_LICENSE_KEY or replace that environment variable with your activation form. Run go run . after installation. A successful run writes licensed-report.txt.

Go · complete main.go
package main

import (
    "context"
    "fmt"
    "os"

    licentivo "github.com/spf86/licentivo-sdk"
)

func run() error {
    ctx, cancel := context.WithCancel(context.Background())
    defer cancel()
    client, err := licentivo.OpenWithLicense(ctx, "product.json",
        os.Getenv("LICENTIVO_LICENSE_KEY"),
        func(err error) { fmt.Fprintln(os.Stderr, "License refresh:", err) })
    if err != nil {
        return err
    }
    defer client.Close()
    err = client.RunFeature("export", func() error {
        return os.WriteFile("licensed-report.txt", []byte("Licensed export\n"), 0600)
    })
    if err != nil {
        return err
    }
    fmt.Println("Created licensed-report.txt")
    return nil
}

func main() {
    if err := run(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}

4. Keep one client for the application lifetime

In a real application, open the client at startup and place RunFeature inside the export button or command handler. Keep the client alive until shutdown. Close stops background work; it preserves ordinary node-locked registration.

The SDK stores a machine-bound credential after activation. Later starts can pass an empty key and restore it from the same user account and cache location. You do not need to store activation IDs or send HTTP heartbeats yourself.

A valid node-locked offline lease can restore immediately while the SDK refreshes online in the background. A floating or online-only policy needs a successful server response. Never treat a logged background error as permission to bypass a failed feature check.

5. Verify allowed and denied operations

  1. Run once with the test key and confirm the report exists.
  2. Remove LICENTIVO_LICENSE_KEY and run again under the same user: saved credentials should restore.
  3. Change export to a feature absent from the license: the operation must return an error without writing a report.
  4. Check an offline restart only when the policy permits it and the signed lease is still valid.

Common integration problems

A missing configuration error usually means product.json is not in the current working directory. Pass an absolute configuration path when launching from a desktop shortcut.

A denied feature requires checking the feature name and license policy; RunFeature checks entitlement, not remaining usage. Use RunMeteredFeature for a counter.

Device limits, an expired license or an explicit server denial require the customer or vendor to resolve authorization. Show the error and request ID where available. Never include vendor management keys in the application.