Skip to content

LicenseFlow/sdk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

licenseflow-go

Official Go SDK for LicenseFlow.

Installation

go get github.com/licenseflow/go-sdk

Quick Start

package main

import (
	"fmt"
	"log"
	"github.com/licenseflow/go-sdk/pkg/licenseflow"
)

func main() {
	client := licenseflow.NewClient(licenseflow.Config{
		BaseURL:   "https://api.licenseflow.dev",
		APIKey:  "your-api-key",
	})

	// 1. Activate License
	res, err := client.Activate("XXXX-YYYY-ZZZZ-AAAA", "Production Server")
	if err != nil {
		log.Fatalf("Activation failed: %v", err)
	}
	fmt.Printf("Activated: %v\n", res["success"])

	// 2. Verify License (Uses internal cache)
	verify, err := client.Verify("XXXX-YYYY-ZZZZ-AAAA")
	if err != nil {
		log.Fatalf("Verification failed: %v", err)
	}
	fmt.Printf("Valid: %v\n", verify["valid"])
}

Features

  • Standard Library: Built using Go standard library for minimal dependencies.
  • Hardware ID: Automatic hostname identification.
  • Thread-safe Caching: Simple in-memory cache for verification.
  • Strongly Typed Errors: Handle RateLimitError and InvalidLicenseError explicitly.

Phase 5: Entitlements

Check feature access based on license tier:

// Check boolean feature
if client.HasFeature(verification, "ai_features") {
    // Enable AI features
}

// Get raw entitlement value
if val := client.GetEntitlement(verification, "max_seats"); val != nil {
    fmt.Printf("Max seats: %v\n", val)
}

Phase 5: Release Management

Check for updates and download new versions:

// Check for updates
update, err := client.CheckForUpdates("prod_123", "v1.0.0", "stable")
if err != nil {
    log.Fatal(err)
}

if update != nil {
    fmt.Printf("New version: %s\n", update["version"])
    
    // Get download URL
    download, err := client.DownloadArtifact("XXXX-YYYY", update["id"].(string), "windows", "x64")
    if err == nil {
        fmt.Printf("Download URL: %s\n", download["url"])
    }
}

Phase 5: Offline Licensing

Verify licenses without internet access:

// Read license file
content, _ := os.ReadFile("license.lic") 
publicKeyHex := "YOUR_ORG_PUBLIC_KEY_HEX"

license, err := client.VerifyOfflineLicense(string(content), publicKeyHex)
if err != nil {
    log.Fatalf("Invalid offine license: %v", err)
}

fmt.Printf("Offline license valid! Customer: %v\n", license["customer_name"])

About

LicenseFlow sdk-go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages