Read label images
Pass a PNG, JPEG, WebP or GIF label file path to scanner.Scan(). A Code 128 label encoding STOCK-4827 returns that exact string.
pkg.go.dev
Zero cgo
1D + 2D
MIT
Decode 1D and 2D barcode files inside Go services using only the standard library, context cancellation and intact leading zeros.
Pass a PNG, JPEG, WebP or GIF label file path to scanner.Scan(). A Code 128 label encoding STOCK-4827 returns that exact string.
Builds with CGO_ENABLED=0 and invokes qrscan directly without a shell so uploaded filenames can never trigger command injection.
Forwards identifiers as Go strings rather than converting them into integers so UPC-A and EAN-13 leading zeros always stay intact.
Install the Go module alongside the qrscan CLI, then extract barcode strings and symbologies with context cancellation.
Requires Go 1.24 or newer and the Go module on pkg.go.dev. Install the matching Barcode Scanner CLI binary separately via Homebrew, Scoop, Cargo, Debian/RPM, AUR, AppImage, GitHub Releases or a container image.
The Go module embeds no decoder and never downloads qrscan at runtime. Keep the module and qrscan binary aligned on the same release line.
go get github.com/qrcode-ai-com/qrcode-barcode-scanner-go@v0.12.2
CGO_ENABLED=0 works out of the box because the Go adapter contains zero C code.
Pass an explicit binary path to qrscan.New("/path/to/qrscan") whenever qrscan sits outside PATH.
Call scanner.Scan with a context, file path, profile and budget, then filter for the barcode symbologies your workflow expects and return exact strings.
To test with a known fixture, generate a Code 128 barcode with Code 128 Barcode Generator encoding STOCK-4827 and scan the exported PNG.
package main
import (
"context"
"fmt"
qrscan "github.com/qrcode-ai-com/qrcode-barcode-scanner-go"
)
type BarcodeReading struct{ Symbology, Text string }
func readBarcodes(ctx context.Context, path string) ([]BarcodeReading, error) {
scanner := qrscan.New("")
report, err := scanner.Scan(ctx, path, qrscan.Frame, qrscan.ProfileBudget)
if err != nil {
return nil, err
}
if !report.Complete {
return nil, fmt.Errorf("scan budget cut before completion")
}
var out []BarcodeReading
for _, d := range report.Detections {
if d.Symbology != "qr_code" && d.Symbology != "micro_qr_code" && d.Symbology != "rectangular_micro_qr_code" {
out = append(out, BarcodeReading{Symbology: d.Symbology, Text: d.Text})
}
}
return out, nil
}
Use qrscan.Frame for fast decode-only scans, or switch to qrscan.Full and qrscan.Unbounded for worn or angled label photos.
Inspect report.JSON directly whenever you need parsed GS1 payloads, occurrences or measured geometry.
For a Code 128 label encoding STOCK-4827, readBarcodes returns BarcodeReading{Symbology: "code128", Text: "STOCK-4827"}. A UPC-A code such as 012345678905 preserves its leading zero intact as a Go string.
A blank image or QR-only file returns an empty slice with a nil error. Check qrscan.ErrBinaryNotFound, *qrscan.UnsupportedVersionError and *qrscan.ScanError (EngineCode such as QRS-001).
Sixteen barcode formats. Because the adapter forwards the qrscan report verbatim, it decodes EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode (ISBN maps to ean13, GS1-128 to code128 and ITF-14 to itf).
Process model and input files. Each Scan() call launches qrscan from an argument slice without a shell (safe for arbitrary filenames). Write in-memory uploads to a temporary file first; this fits HTTP handlers and batch jobs rather than tight frame loops.
Exact strings and licence. Identifiers stay Go strings so leading zeros never vanish, and catalogue lookups stay in your own database. Adapter source is MIT-licensed; see the Go adapter README and Go module GitHub repository.
Official package guides, ScanReport specification and licensing references.
cgo, qrscan prerequisite, formats, leading zeros, errors and licensing.
It is QR Code AI’s open-source MIT-licensed Go module (github.com/qrcode-ai-com/qrcode-barcode-scanner-go) that drives the separately installed qrscan CLI using only Go’s standard library and returns decoded barcode strings and symbologies verbatim.
No. It requires Go 1.24 or newer and compiles cleanly with CGO_ENABLED=0. You only need a matching qrscan binary installed on your host or container.
It returns every symbol supported by the installed qrscan engine: 16 barcode formats (EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode) alongside QR Code, Micro QR and rMQR.
Yes to leading zeros, no to product lookups. The adapter forwards identifiers as Go strings rather than parsing them into integers, so UPC-A and EAN-13 leading zeros stay intact. Query your own catalogue or inventory database separately.
Earlier wazero WebAssembly trials produced identical reports but ran roughly twenty times slower on photo-sized images. Driving native qrscan keeps full native performance without cgo, fitting request handlers and batch jobs (for tight in-process loops, use Rust, Node.js, Python or .NET).
A blank image returns report.Found() == false with err == nil (verify report.Complete is true). Errors are signalled via ErrBinaryNotFound, *UnsupportedVersionError, *ScanError (with EngineCode such as QRS-001) or the context error.
No. Both the Go adapter and qrscan execute 100% locally with zero network calls, no QR Code AI account, no API key and no creation credits.
Yes. Current releases of the Go adapter and qrscan engine ship under the MIT licence for commercial and proprietary software while keeping copyright and licence notices intact (see LICENSING.md). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.