> For the complete documentation index, see [llms.txt](https://docs.licensespring.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.licensespring.com/sdks/go-sdk/v2/go-sdk-v2.md).

# Go SDK V2

### License Manager

The LicenseManager is the core module responsible for managing licenses, communicating with the LicenseSpring server, and handling authentication.

#### Struct Definition

{% code title="license\_manager.go" %}

```go
type LicenseManager struct {
   LicenseClient license_client.LicenseClient
   LicenseData   *types.LicenseData
   types.OfflineActivationGuard
}
```

{% endcode %}

#### Constructor Functions

To create a new license manager, use:

{% code title="constructors.go" %}

```go
NewLicenseManager(apiKey, sharedKey, productCode string, authData auth.Auth, opts ...ConfigurationOption) (*LicenseManager, error)
```

{% endcode %}

### License Client Configuration

The LicenseManager includes a LicenseClient, which contains all configuration for interacting with the server:

{% code title="license\_client.go" %}

```go
type LicenseClient struct {
   c *client.Client
   LicenseClientConfiguration
}
```

{% endcode %}

### Storage

Storage is responsible for securely persisting license-related data such as license files, guard files, and encrypted custom data.

### License Handler

The LicenseHandler is the user-facing layer that wraps the LicenseManager and Storage. It acts as a coordinator:

* Calls the license manager to perform actions (e.g. activation)
* Persists the resulting data to storage (e.g. license file)
* Manages offline guard file storage
* Decouples core logic (license manager) from the storage mechanism

#### Example: License Activation Flow

{% code title="license\_handler\_example.go" %}

```go
func (lh *LicenseHandler) ActivateLicense(ctx context.Context) error {
    dl, err := lh.LicenseManager.ActivateLicense(ctx)
    if err != nil {
        return err
    }
    err = lh.Storage.SaveLicense(dl)
    if err != nil {
        return errors.LicenseDataStorageFailed()
    }
    return nil
}
```

{% endcode %}

{% hint style="info" %}
The LicenseManager is completely decoupled from the storage implementation. This allows the replacement of the storage layer without changing the license logic.

For example, when floating server support is added in the future:

* We can implement a new Storage logic
* Use the existing LicenseManager as-is
* Replace LicenseHandler with a FloatingServerHandler or similar
  {% endhint %}

More details about license handler in next section.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.licensespring.com/sdks/go-sdk/v2/go-sdk-v2.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
