barcodes/generation/generate.go

37 lines
836 B
Go

package generation
import (
"fmt"
"github.com/boombuler/barcode"
)
func Generate(parameters Parameters) (barcode.Barcode, error) {
var barcode_content barcode.Barcode
var err error
switch parameters.Format {
case Aztec:
barcode_content, err = generateAztec(parameters)
case Codabar:
barcode_content, err = generateCodabar(parameters)
case Code93:
barcode_content, err = generateCode93(parameters)
case Code128:
barcode_content, err = generateCode128(parameters)
case QR:
barcode_content, err = generateQr(parameters)
case Datamatrix:
barcode_content, err = generateDatamatrix(parameters)
default:
fmt.Println("Unsupported barcode type: ", parameters.Format)
}
if err != nil {
fmt.Println("Generation Error: ", err)
return nil, err
}
fmt.Println("Barcode Generated")
return barcode_content, err
}