github.com/unidoc/unidoc@v2.2.0+incompatible/common/license/util.go (about) 1 /* 2 * This file is subject to the terms and conditions defined in 3 * file 'LICENSE.md', which is part of this source code package. 4 */ 5 6 // The license package helps manage commercial licenses and check if they are valid for the version of unidoc used. 7 package license 8 9 // Defaults to the open source license. 10 var licenseKey *LicenseKey = MakeUnlicensedKey() 11 12 // Sets and validates the license key. 13 func SetLicenseKey(content string) error { 14 lk, err := licenseKeyDecode(content) 15 if err != nil { 16 return err 17 } 18 19 err = lk.Validate() 20 if err != nil { 21 return err 22 } 23 24 licenseKey = &lk 25 26 return nil 27 } 28 29 func GetLicenseKey() *LicenseKey { 30 if licenseKey == nil { 31 return nil 32 } 33 34 // Copy. 35 lk2 := *licenseKey 36 return &lk2 37 }