barcodes/generation/qr.go

29 lines
487 B
Go
Raw Normal View History

2023-09-01 20:50:47 +01:00
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
}