-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathmain.go
43 lines (36 loc) · 959 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* license/offline/main.go:
* Illustrates how to load an offline (perpetual) license key.
* Offline keys can be purchased at https://www.unidoc.io
*
* Run as: go run main.go
*/
package main
import (
"fmt"
"github.com/unidoc/unioffice/common/license"
)
// Example of an offline perpetual license key.
const offlineLicenseKey = `
-----BEGIN UNIDOC LICENSE KEY-----
contents here.
-----END UNIDOC LICENSE KEY-----
`
func init() {
// The customer name needs to match the entry that is embedded in the signed key.
customerName := `My Company`
// Good to load the license key in `init`. Needs to be done prior to using the library, otherwise operations
// will result in an error.
err := license.SetLicenseKey(offlineLicenseKey, customerName)
if err != nil {
panic(err)
}
}
func main() {
lk := license.GetLicenseKey()
if lk == nil {
fmt.Printf("Failed retrieving license key")
return
}
fmt.Printf("License: %s\n", lk.ToString())
}