Go Barcode Scanner SDK

Add offline 1D and 2D barcode scanning to your Go service or batch job without cgo. The MIT-licensed Go adapter relies solely on the standard library, drives your installed qrscan binary and returns exact string identifiers paired with their symbology.

Text
import (
	"fmt"
	qrscan "github.com/qrcode-ai-com/qrcode-barcode-scanner-go"
)

scanner := qrscan.New("")
report, err := scanner.Scan(ctx, "label.png", qrscan.Frame, qrscan.ProfileBudget)
var text string
for _, d := range report.Detections { if d.Symbology == "code128" { text = d.Text; break } }

if err == nil { fmt.Println(text) }

Inspect the decoded identifierSTOCK-4827

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.

go get github.com/qrcode-ai-com/qrcode-barcode-scanner-go@v0.12.2

Need to scan a barcode right away? Open online reader

Go Barcode Scanner SDK at a glance

  • Standard library only, Go 1.24+

    pkg.go.dev

  • Builds cleanly with CGO_ENABLED=0

    Zero cgo

  • EAN, UPC, Code 128, Data Matrix & more

    1D + 2D

  • Open-source licence

    MIT

Add barcode scanning to Go without cgo

Decode 1D and 2D barcode files inside Go services using only the standard library, context cancellation and intact leading zeros.

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.

No cgo, standard library only

Builds with CGO_ENABLED=0 and invokes qrscan directly without a shell so uploaded filenames can never trigger command injection.

Keep exact strings & formats

Forwards identifiers as Go strings rather than converting them into integers so UPC-A and EAN-13 leading zeros always stay intact.

Add barcode image reading in Go

Install the Go module alongside the qrscan CLI, then extract barcode strings and symbologies with context cancellation.

Install the Go module and qrscan CLI

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.

Decode a barcode label file in Go

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.

Text
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.

Inspect the decoded identifier

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).

Subprocess architecture, barcode formats and safety

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.

Go Barcode Scanner documentation and licence

Official package guides, ScanReport specification and licensing references.

Go Barcode Scanner SDK questions

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.