linkAuto-updates for Go programs
You can integrate our Go SDK to implement license activation and automatic upgrades into your Go program. Installing an upgrade will replace the currently running binary with the new binary. After a restart, the end-user will be on the upgraded version.
Configuration
| Variable | Required | Description |
|---|---|---|
keygen.Account |
Yes | Your Keygen account ID. You can find your account ID here. |
keygen.Product |
Yes | Your Keygen product ID. You can find your product here. |
keygen.LicenseKey |
No | A license key used for API authentication. This will be used for license validations, activations, and for licensed upgrades. |
keygen.Token |
No | A license token used for API authentication. This will be used for license validations, activations, and for licensed upgrades. |
Whether to use LicenseKey or Token depends on the license policy's authentication strategy.
Setting it to LICENSE will require a license key, TOKEN a license token, and MIXED
will allow either. LicenseKey will take precedence over Token if both are provided.
If your product uses an OPEN distribution strategy, a LicenseKey or Token is not required.
Example main.go
import "github.com/keygen-sh/keygen-go" func upgrade() error { keygen.Account = "1fddcec8-8dd3-4d8d-9b16-215cac0f9b52" keygen.Product = "1f086ec9-a943-46ea-9da4-e62c2180c2f4" keygen.LicenseKey = "C1B6DE-39A6E3-DE1529-8559A0-4AF593-V3" opts := keygen.UpgradeOptions{CurrentVersion: "1.0.0", Channel: "stable", PublicKey: "5ec69b78d4b5d4b624699cef5faf3347dc4b06bb807ed4a2c6740129f1db7159"} // Check for an upgrade release, err := keygen.Upgrade(opts) switch { case err == keygen.ErrUpgradeNotAvailable: fmt.Println("No upgrade available, already at the latest version!") return nil case err != nil: fmt.Println("Upgrade check failed!") return err } // Install the upgrade if err := release.Install(); err != nil { panic("Upgrade install failed!") } fmt.Printf("Upgrade complete! Installed v%s. Please restart.\n", release.Version)}