@@ -19,7 +19,7 @@ func Example_complete() {
1919 // create a new Private key:
2020 privateKey , err := lk .NewPrivateKey ()
2121 if err != nil {
22- log .Fatal (err )
22+ log .Fatal ("private key generation failed: " + err . Error () )
2323
2424 }
2525
@@ -39,15 +39,14 @@ func Example_complete() {
3939 // generate your license with the private key and the document:
4040 license , err := lk .NewLicense (privateKey , docBytes )
4141 if err != nil {
42- log .Fatal (err )
42+ log .Fatal ("license generation failed: " + err . Error () )
4343
4444 }
4545
4646 // encode the new license to b64, this is what you give to your customer.
4747 str64 , err := license .ToB64String ()
4848 if err != nil {
4949 log .Fatal (err )
50-
5150 }
5251 fmt .Println (str64 )
5352
@@ -57,7 +56,7 @@ func Example_complete() {
5756
5857 // validate the license:
5958 if ok , err := license .Verify (publicKey ); err != nil {
60- log .Fatal (err )
59+ log .Fatal ("license verification failed: " + err . Error () )
6160 } else if ! ok {
6261 log .Fatal ("Invalid license signature" )
6362 }
@@ -101,22 +100,24 @@ func Example_licenseGeneration() {
101100 // Unmarshal the private key:
102101 privateKey , err := lk .PrivateKeyFromB32String (privateKeyBase32 )
103102 if err != nil {
104- log .Fatal (err )
103+ log .Fatal ("private key unmarshal failed: " + err . Error () )
105104 }
106105
107106 // generate your license with the private key and the document:
108107 license , err := lk .NewLicense (privateKey , docBytes )
109108 if err != nil {
110- log .Fatal (err )
111-
109+ log .Fatal ("license generation failed: " + err .Error ())
112110 }
111+
113112 // the b32 representation of our license, this is what you give to
114113 // your customer.
115114 licenseB32 , err := license .ToB32String ()
116115 if err != nil {
117- log .Fatal (err )
116+ log .Fatal ("license encoding failed: " + err . Error () )
118117
119118 }
119+
120+ // print the license that you should give to your customer
120121 fmt .Println (licenseB32 )
121122}
122123
@@ -125,7 +126,7 @@ func Example_licenseGeneration() {
125126func Example_licenseVerification () {
126127
127128 // A previously generated licence b32 encoded. In real life you should read
128- // it from a file at the beginning of your program and check it
129+ // it from a file (or prompt the user) at the beginning of your program and check it
129130 // before doing anything else...
130131 const licenseB32 = "FT7YOAYBAEDUY2LDMVXHGZIB76EAAAIDAECEIYLUMEAQUAABAFJAD74EAAAQCUYB76CAAAAABL7YGBIBAL7YMAAAAD73H74IAFEHWITFNVQWS3BCHIRHIZLTORAGK6DBNVYGYZJOMNXW2IRMEJSW4ZBCHIRDEMBRHAWTCMBNGI3FIMJSHIYTSORTGMXDOMBZG43TIMJYHAVTAMR2GAYCE7IBGEBAPXB37ROJCUOYBVG4LAL3MSNKJKPGIKNT564PYK5X542NH62V7TAUEYHGLEOPZHRBAPH7M4SC55OHAEYQEXMKGG3JPO6BSHTDF3T5H6T42VUD7YAJ3TY5AP5MDE5QW4ZYWMSAPEK24HZOUXQ3LJ5YY34XYPVXBUAA===="
131132
@@ -137,18 +138,18 @@ func Example_licenseVerification() {
137138 // Unmarshal the public key
138139 publicKey , err := lk .PublicKeyFromB32String (publicKeyBase32 )
139140 if err != nil {
140- log .Fatal (err )
141+ log .Fatal ("public key unmarshal failed: " + err . Error () )
141142 }
142143
143144 // Unmarshal the customer license:
144145 license , err := lk .LicenseFromB32String (licenseB32 )
145146 if err != nil {
146- log .Fatal (err )
147+ log .Fatal ("license unmarshal failed: " + err . Error () )
147148 }
148149
149150 // validate the license signature:
150151 if ok , err := license .Verify (publicKey ); err != nil {
151- log .Fatal (err )
152+ log .Fatal ("license verification failed: " + err . Error () )
152153 } else if ! ok {
153154 log .Fatal ("Invalid license signature" )
154155 }
0 commit comments