Go SDK
Use this page to integrate LicenseKit from Go with the first-party github.com/drmain1/licensekit-go module.
Who This Is For
- Go developers building backend tooling or service integrations
- teams that want a typed module generated from the LicenseKit contract
- AI agents generating Go integration code
When To Use This
Use this page when your integration language is Go and you want a generated client plus verification helpers.
How It Works
Install
bash
go get github.com/drmain1/licensekit-goClient split
The module exposes:
ManagementClientRuntimeClientSystemClient- public-key verification helpers
- scope metadata helpers
Auth split
- management routes use bearer auth
- runtime routes use license auth
- system routes use no auth
Reporting support
The management client includes the reporting operations, including reads and frozen export flows.
Typical reporting methods follow the generated operationId-derived names:
ListActivitiesGetUsageSummaryListUsageLedgerGetLicenseAuditReportGetCustomerSummaryGetSubscriptionSettlementCreateReportExportGetReportExportDownloadReportExport
Scope metadata
Use the generated scope helpers for least privilege:
go
required, ok := licensekit.GetRequiredScopes(licensekit.ManagementOperationCreateReportExport)
allowed := licensekit.HasRequiredScopes(
licensekit.ManagementOperationGetUsageSummary,
[]string{"report:read"},
)
_ = required
_ = ok
_ = allowedExample
Runtime validation and verification:
go
package main
import (
"context"
"log"
licensekit "github.com/drmain1/licensekit-go"
)
func main() {
ctx := context.Background()
baseURL := "https://api.licensekit.dev"
runtime, err := licensekit.NewRuntimeClient(licensekit.RuntimeClientOptions{
ClientOptions: licensekit.ClientOptions{BaseURL: baseURL},
LicenseKey: "lsk_...",
})
if err != nil {
log.Fatal(err)
}
system, err := licensekit.NewSystemClient(licensekit.SystemClientOptions{
BaseURL: baseURL,
})
if err != nil {
log.Fatal(err)
}
fingerprint := "host-123"
result, err := runtime.ValidateLicense(ctx, licensekit.ValidateLicenseJSONRequestBody{
Fingerprint: &fingerprint,
})
if err != nil {
log.Fatal(err)
}
publicKeys, err := system.ListPublicKeys(ctx)
if err != nil {
log.Fatal(err)
}
_, err = licensekit.VerifyRuntimeResult(result, licensekit.NewPublicKeyStore(publicKeys.Data))
if err != nil {
log.Fatal(err)
}
}Reporting read example:
go
management, err := licensekit.NewManagementClient(licensekit.ManagementClientOptions{
ClientOptions: licensekit.ClientOptions{BaseURL: baseURL},
Token: "lkm_...",
})
if err != nil {
log.Fatal(err)
}
customerID := "cust_123"
limit := 50
activities, err := management.ListActivities(ctx, &licensekit.ListActivitiesParams{
CustomerId: &customerID,
Limit: &limit,
})
if err != nil {
log.Fatal(err)
}Common Mistakes
- assuming the Go module only covers core licensing and not reporting
- using a runtime client where a management client is required
- ignoring the scope metadata helpers and overusing admin tokens
- trusting runtime data without calling verification helpers