> 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/floating-license.md).

# Floating License

### License Check

{% hint style="info" %}
If the license is of **floating cloud** type, calling `CheckLicense` will automatically assign one floating slot to the current machine, identified by its hardware ID.
{% endhint %}

The `CheckLicense` function is not only used to validate the current license status, but also plays a role in floating licenses.

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

```go
ld, err = lh.CheckLicense(ctx)
if err != nil {
	return err
}
```

{% endcode %}

### Borrow

Floating licenses come with a predefined **floating period**—a time frame in which the license is valid on a given machine. If the license configuration allows, this period can be **borrowed** or **extended** for offline usage.

You can extend the floating period using one of two methods:

{% stepper %}
{% step %}

### Borrow for a Specific Number of Hours and Days

{% code title="borrow\_hours\_days.go" %}

```go
ld, err = lh.BorrowHoursAndDays(ctx, 3, 0)
if err != nil {
	return err
}
```

{% endcode %}

These functions will only succeed if the license allows borrowing and there are available slots or permissions for the request.
{% endstep %}

{% step %}

### Borrow Until a Specific Time

{% code title="borrow\_until.go" %}

```go
t := time.Now().Add(3 * time.Hour).UTC()
ld, err = lh.Borrow(ctx, &t)
if err != nil {
	fmt.Println("license borrow error: %w", err)
	return err
}
```

{% endcode %}

These functions will only succeed if the license allows borrowing and there are available slots or permissions for the request.
{% endstep %}
{% endstepper %}

### Release Floating License

If you no longer need the license on the current machine, or want to release a floating slot before the borrow period ends, you can call:

{% code title="release\_floating.go" %}

```go
ld, err = lh.ReleaseFloatingLicense(ctx)
if err != nil {
	return err
}
```

{% endcode %}

This function immediately frees up the slot assigned to the current machine, making it available for others.


---

# 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/floating-license.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.
