29 lines
487 B
Go
29 lines
487 B
Go
|
package generation
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/boombuler/barcode"
|
||
|
"github.com/boombuler/barcode/qr"
|
||
|
)
|
||
|
|
||
|
func generateQr(parameters Parameters) (barcode.Barcode, error) {
|
||
|
var level qr.ErrorCorrectionLevel
|
||
|
switch parameters.ECCLevel {
|
||
|
case 1:
|
||
|
level = qr.L
|
||
|
case 2:
|
||
|
level = qr.M
|
||
|
case 3:
|
||
|
level = qr.Q
|
||
|
case 4:
|
||
|
level = qr.H
|
||
|
}
|
||
|
qrCode, err := qr.Encode(parameters.Content, level, qr.Auto)
|
||
|
if err != nil {
|
||
|
fmt.Println("Error creating Barcode", err)
|
||
|
}
|
||
|
|
||
|
return qrCode, err
|
||
|
}
|