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 uses only the standard library, invokes your installed qrscan binary and returns exact string identifiers 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

Want to scan a barcode now? Open the 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 license

    MIT

Add barcode scanning to Go without cgo

Decode 1D and 2D barcode files in Go services with standard library only, 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

Compiles with CGO_ENABLED=0 and starts qrscan directly without a shell so uploaded filenames cannot inject commands.

Keep exact strings & formats

Forwards identifiers as Go strings (never converting them to integers) so UPC-A and EAN-13 leading zeros always survive.

Add barcode image reading in Go

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

Install the Go module and qrscan CLI

Requires Go 1.24 or later 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 container image.

The Go module embeds no decoder and never downloads qrscan at runtime. Keep the module and qrscan binary on the same release line.

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

CGO_ENABLED=0 is fully supported because the Go adapter contains zero C code.

Pass an explicit path to qrscan.New("/path/to/qrscan") when qrscan lives outside PATH.

Decode a barcode label file in Go

Call scanner.Scan with a context, file path, profile and budget, then keep the barcode symbologies your workflow expects and return exact strings.

To test with a known reference, create a Code 128 barcode with 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 decoding only, or switch to qrscan.Full and qrscan.Unbounded for difficult label photos.

Read report.JSON directly when 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 label such as 012345678905 keeps its leading zero intact as a Go string.

A blank image or QR-only file returns an empty slice and 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 reads 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, ITF-14 to itf).

Process model and input files. Each Scan() spawns qrscan from an argument slice without a shell (safe for arbitrary filenames). Write in-memory uploads to a temporary file first; this fits requests and batch jobs rather than tight frame loops.

Exact strings and license. Identifiers stay strings so leading zeros never drop, and product lookups remain in your own database. Adapter source is MIT; see the Go adapter README and Go module repository.

Go Barcode Scanner documentation and license

Official package documentation, 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 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 unchanged.

No. It requires Go 1.24 or later and builds cleanly with CGO_ENABLED=0. You only need a compatible qrscan binary installed on your host or container.

It returns whatever the installed qrscan engine decodes: 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) plus QR Code, Micro QR and rMQR.

Yes to leading zeros, no to product lookups. The adapter forwards identifiers as Go strings instead of converting them into integers, so UPC-A and EAN-13 leading zeros stay intact. Query your own catalog or inventory database separately.

Earlier wazero WebAssembly tests produced identical reports but ran roughly twenty times slower on photo-sized images. Invoking native qrscan keeps native speed without cgo, fitting request handlers and batch jobs (for tight loops, use Rust, Node.js, Python or .NET).

A blank image returns report.Found() == false with err == nil (verify report.Complete is true). Errors surface as ErrBinaryNotFound, *UnsupportedVersionError, *ScanError (with EngineCode such as QRS-001) or the context error.

No. Both the Go adapter and qrscan run 100% locally with no network requests, no QR Code AI account, no API key and no creation credits.

Yes. Current releases of the Go adapter and qrscan engine are MIT-licensed for commercial and proprietary applications while keeping copyright and license notices (see LICENSING.md). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.