Floating License

License Check

circle-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.

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

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

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:

1

Borrow for a Specific Number of Hours and Days

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

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

2

Borrow Until a Specific Time

borrow_until.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
}

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

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:

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

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

Was this helpful?