Go QR Code Scanner SDK

Add offline QR code scanning to your Go microservice, batch worker or CLI utility with zero cgo. The MIT-licensed Go adapter relies solely on the standard library, drives your installed qrscan binary and returns the engine’s JSON report verbatim.

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 == "qr_code" { text = d.Text; break } }

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

Inspect the decoded resulthttps://qrcode-ai.com/

Read saved QR images

Pass a file path (PNG, JPEG, WebP or GIF) to scanner.Scan() and receive decoded QR text, raw bytes and scannability score.

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

Need to scan a QR code right away? Open the online reader

Go QR Code Scanner SDK at a glance

  • Standard library only, Go 1.24+

    pkg.go.dev

  • Builds cleanly with CGO_ENABLED=0

    Zero cgo

  • Drives separately installed CLI

    Uses qrscan

  • Open-source licence

    MIT

Add QR scanning to Go without cgo

Invoke the native qrscan binary from Go’s standard library with context cancellation and zero C compilation.

Read saved QR images

Pass a file path (PNG, JPEG, WebP or GIF) to scanner.Scan() and receive decoded QR text, raw bytes and scannability score.

No cgo, standard library only

Compiles cleanly with CGO_ENABLED=0 and executes qrscan directly without a shell so untrusted filenames stay safe.

Read structured Go fields

Inspect report.Found(), Detections, Score, Complete and report.JSON (verbatim engine output) with typed Go error checks.

Add QR image scanning in Go

Install the Go module alongside the qrscan CLI, then decode an image file using a Go context.

Install the Go module and qrscan CLI

Requires Go 1.24 or newer and the Go module on pkg.go.dev. Install the matching QR Code Scanner CLI binary separately via Homebrew, Scoop, Cargo, Debian/RPM, AUR, AppImage, GitHub Releases or container image.

The Go module embeds no decoder of its own and never fetches qrscan at runtime. Keep both on the same release line so the startup version check passes.

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

CGO_ENABLED=0 works out of the box because the adapter includes zero C source files.

Supply an explicit binary path to qrscan.New("/path/to/qrscan") whenever qrscan is outside PATH.

Decode a QR image file with context

Initialise a scanner via qrscan.New(""), invoke scanner.Scan with a context, profile and budget, and keep detections whose Symbology equals qr_code. Cancelling ctx terminates the qrscan subprocess cleanly.

Text
package main

import (
	"context"
	"fmt"

	qrscan "github.com/qrcode-ai-com/qrcode-barcode-scanner-go"
)

func readQRImage(ctx context.Context, path string) ([]string, error) {
	scanner := qrscan.New("")
	report, err := scanner.Scan(ctx, path, qrscan.Full, qrscan.ProfileBudget)
	if err != nil {
		return nil, err
	}
	if !report.Complete {
		return nil, fmt.Errorf("scan budget cut before completion")
	}
	var urls []string
	for _, d := range report.Detections {
		if d.Symbology == "qr_code" {
			urls = append(urls, d.Text)
		}
	}
	return urls, nil
}

Pick qrscan.Frame (decode only, nil Score), qrscan.Fast (lighter scoring) or qrscan.Full (complete QR quality assessment).

Supply qrscan.Unbounded instead of qrscan.ProfileBudget whenever you want reproducible scans unaffected by host CPU load.

Inspect the decoded result

For a QR image encoding https://qrcode-ai.com/, readQRImage returns []string{"https://qrcode-ai.com/"}. Read report.JSON whenever you require the full, unmodified engine JSON including geometry, payloads and trace.

Finding no code is a normal outcome: report.Found() is false and err is nil. Branch on qrscan.ErrBinaryNotFound (via errors.Is), *qrscan.UnsupportedVersionError, *qrscan.ScanError (EngineCode such as QRS-001) or the context error.

Subprocess architecture, safety and workload fit

One subprocess per scan. Each Scan() call launches qrscan directly from an explicit argument slice without invoking a shell, so filenames containing spaces, quotes or leading dashes are never parsed by a shell. This design suits HTTP handlers and batch jobs rather than tight loops over thousands of frames.

File inputs and why not WASM. Pass PNG, JPEG, WebP or GIF file paths (write in-memory uploads to a temporary file first). Running the native qrscan binary avoids the roughly twentyfold slowdown observed in earlier wazero WebAssembly experiments.

Untrusted payloads and licence. Treat every decoded string as untrusted input and never open URLs automatically. Project-authored adapter code is MIT-licensed; see the Go adapter README and Go module repository.

Go QR Code Scanner documentation and licence

Official module guides, ScanReport schema specification and licensing notices.

Go QR Code Scanner SDK questions

cgo, qrscan prerequisite, contexts, budgets, error types, offline use 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 a separately installed qrscan binary using only the Go standard library and returns the ScanReport verbatim.

No. It requires Go 1.24 or later, relies exclusively on the standard library and builds cleanly with CGO_ENABLED=0. You only need the native qrscan binary present on your host or container image.

An earlier prototype running the engine inside Go via wazero produced identical reports but took roughly twenty times longer on photo-sized inputs. Calling native qrscan keeps native decoding speed without cgo build overhead.

Scan() accepts a file path (PNG, JPEG, WebP or GIF), so write in-memory bytes to a temporary file before scanning. Since every call spawns a qrscan subprocess, it fits HTTP handlers and batch jobs well; for high-throughput in-process frame loops, consider the Rust, Node.js, Python or .NET bindings.

When no code is detected, report.Found() is false and err is nil. If report.Complete is false, the budget ended the scan early and an empty result is not final; retry with qrscan.Unbounded. Hard failures return ErrBinaryNotFound, *UnsupportedVersionError, *ScanError (carrying EngineCode) or ctx.Err().

Yes. The adapter invokes qrscan via an explicit argument slice without any shell, ensuring spaces, quotes, leading dashes and shell metacharacters in file paths are never interpreted.

Yes. The adapter writes nothing to disk, makes zero network requests and never opens decoded URLs. Decoding executes entirely locally on your host or container without a QR Code AI account or API key.

Yes. Current releases of both the Go adapter and the qrscan engine ship under the MIT licence for commercial and proprietary services while preserving copyright and licence notices (check LICENSING.md). SDK usage is independent of QR Code AI’s paid creation plans and seven-day Premium trial.