> 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/samples/features.md).

# Features

Licenses in our SDK support **features.** A license can contain multiple features; each with its own behavior and rules. These features can be of different types, such as **floating** or **consumption.**

### Floating Features

In the case of **floating features**, the SDK provides functionality similar to floating licenses. A floating feature allows a client to check out a floating slot for a limited time (the **floating period**), after which the slot expires unless explicitly released earlier.

Both the local license file and the LicenseSpring platform will reflect the current status of floating slots in use.

{% stepper %}
{% step %}

#### Checking out a floating feature

To occupy a floating slot for a feature, use `CheckLicenseFeature`. Once called, the SDK will store the updated slot usage locally, and you can inspect it using `GetFeature(featureCode)` on the license data:

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

```go
	ld, err = lh.CheckLicenseFeature(ctx, featureCode)
	if err != nil {
		fmt.Println("feature check error: %w", err)
		return err
	}
	feature := ld.GetFeature(featureCode)
	fmt.Printf("Floating slots in use: %d\n", feature.FloatingInUseCount)
```

{% endcode %}

The `FloatingInUseCount` field indicates how many devices are currently using that feature under this license.
{% endstep %}

{% step %}

#### Releasing a floating feature

To release a floating slot before the end of the floating period (for example, when shutting down the application), use the following:

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

```go
	ld, err = lh.ReleaseFloatingLicenseFeature(ctx, featureCode)
	if err != nil {
		fmt.Println("error releasing floating feature: %w", err)
		return err
	}
	feature = ld.GetFeature(featureCode)
	fmt.Printf("Floating slots in use: %d\n", feature.FloatingInUseCount)
```

{% endcode %}

Releasing the slot will update both the local license data and the LicenseSpring platform, freeing the slot for other devices.
{% endstep %}
{% endstepper %}

### Consumption Features

Features of the consumption type allow your application to consume usage limits tied to that feature. These consumptions may be limited or unlimited, depending on how the feature is configured in the LicenseSpring platform.

Similar to consumption licenses, consumption-based features support local usage updates that can later be synced to the cloud.

{% stepper %}
{% step %}

#### Local consumption update

To register the consumption of a feature locally (i.e., increase usage before syncing to the cloud), use the `UpdateFeatureConsumption()` method. This updates the `LocalConsumptions` field in your locally stored license file.

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

```go
	ld, err = lh.UpdateFeatureConsumption(featureCode, 1, true)
	if err != nil {
		return err
	}

	feature := ld.GetFeature(featureCode)
	t := feature.TotalConsumptions
	l := feature.LocalConsumptions
	fmt.Printf("Total Consumptions: %d\n  Local Consumptions: %d\n", t, l)
```

{% endcode %}

The third argument to `UpdateFeatureConsumption()` controls whether the local file should be updated in addition to in-memory data, which is what we recommend.
{% endstep %}

{% step %}

#### Sync with LicenseSpring server

To commit the locally recorded consumption to the LicenseSpring backend, call `SyncFeatureConsumption()`.

You can provide:

* One or more feature codes to sync specific features.
* No arguments to sync **all** consumption features at once.

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

```go
	ld, err = lh.SyncFeatureConsumption(ctx, featureCode)
	if err != nil {
		return err
	}
	feature = ld.GetFeature(featureCode)
	t = feature.TotalConsumptions
	l = feature.LocalConsumptions
	fmt.Printf("Total Consumptions: %d\n  Local Consumptions: %d\n", t, l)
```

{% endcode %}

After syncing:

* `TotalConsumptions` will reflect the updated count on the LicenseSpring platform.
* `LocalConsumptions` will be reset to 0.
  {% endstep %}
  {% endstepper %}


---

# 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 current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
