Go SDK
Go SDK
Pure Go 1.21+ client, standard library only — crypto/ecdsa handles offline
token verification natively, so unlike SDKs built on OpenSSL/PHP-openssl/Python
cryptography this needs no raw-signature-to-DER conversion step. No third-party
packages at all.
Installation
Not yet published as a tagged Go module — download the source ZIP above, extract it, then
add a replace directive to your own go.mod pointing at the
extracted folder:
require github.com/permitCore-spec/permitcore-sdk-go v0.0.0
replace github.com/permitCore-spec/permitcore-sdk-go => ./permitcore-sdk-go
Quick start — validate
import "github.com/permitCore-spec/permitcore-sdk-go"
client := permitcore.New("https://api.permitcore.dev")
result := client.Validate("PERMIT-XXXX-XXXX-XXXX-XXXX", "")
if !result.IsValid {
log.Fatalf("License invalid: %s", result.Message)
}
if result.HasFeature("export") {
enableExport()
}
Activate (call once per installation)
result := client.Activate(
"PERMIT-XXXX-XXXX-XXXX-XXXX",
"", // deviceId — auto-generated HWID when empty
"Production Server #1", // deviceName
"", // version, optional
)
if !result.IsValid {
log.Fatalf("Activation failed: %s", result.Message)
}
// Save result.IsValid to local storage — use Validate() on every subsequent launch.
Metered billing
// Record a single event
client.Meter(licenseKey, "api_call", 1, nil)
// Record bulk usage with metadata
client.Meter(licenseKey, "export", 5, map[string]any{"format": "pdf", "pages": 12})
Floating licenses
// Check out a seat at session start
session := client.Checkout(licenseKey, "", "")
if !session.Success {
log.Fatalf("No seats available: %s", session.Message)
}
token := session.SessionToken
// Heartbeat every 4-5 minutes to keep the seat alive
client.Heartbeat(token)
// Release the seat when done
client.Checkin(token)
Offline grace period
result := client.Validate(licenseKey, "") // falls back to disk cache automatically
if result.IsOffline {
// Running on cached result — server unreachable
showNotice("Running offline. Connect to refresh your license.")
}
Offline license tokens
No extra package needed — crypto/ecdsa is standard library. Verification is
pure local ECDSA P-256/SHA-256, zero network calls:
result := permitcore.VerifyOfflineToken(token, publicKeyBase64)
if result.IsValid {
fmt.Println("Valid! Product:", result.Payload.ProductName)
}
// Bind to this device + persist locally (call once, e.g. at install time)
result = permitcore.ActivateOffline(token, publicKeyBase64, deviceID)
// On every later launch — no token needed, reads the local cache
result = permitcore.ValidateOffline(deviceID)
LicenseResult reference
| Field | Type | Description |
|---|---|---|
IsValid | bool | True if the license is active and valid |
ProductName | string | Product the license belongs to |
RemainingActivations | *int | Activation slots remaining |
ExpiresAt | string | ISO 8601 expiry date, empty = perpetual |
Features | []string | Feature flag list, e.g. ["export","api"] |
IsTrial | bool | True for trial licenses |
TrialDaysRemaining | *int | Days until trial expires |
NodeLocked | bool | True if bound to a specific device |
OfflineGraceDays | *int | How many days the cache remains valid |
MinVersion / MaxVersion | string | Version enforcement bounds |
VendorWarning | string | Non-fatal message from the vendor |
Message | string | Reason when IsValid == false |
IsOffline | bool | True when result came from local cache |
ErrorCode | string | Stable, machine-readable failure reason |
HasFeature(feature string) bool — case-insensitive check whether a feature flag is present on the license.