Go QR Code Scanner SDK

Add offline QR code scanning to your Go service, batch job or CLI tool 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 an image file path (PNG, JPEG, WebP or GIF) to scanner.Scan() to get decoded QR text, raw bytes and score.

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

Need to scan a code right away? Open 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

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

Read saved QR images

Pass an image file path (PNG, JPEG, WebP or GIF) to scanner.Scan() to get decoded QR text, raw bytes and score.

No cgo, standard library only

Compiles cleanly with CGO_ENABLED=0 and invokes the installed qrscan binary directly without a shell so arbitrary filenames stay safe.

Read structured Go fields

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

Add QR image reading in Go

Install the Go module alongside the qrscan CLI, then decode an image file with 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 a container image.

The Go module embeds no decoder of its own and never downloads qrscan at runtime. Keeping both on the same release line satisfies the startup version check.

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 contains zero C code.

Pass an explicit path to qrscan.New("/path/to/qrscan") whenever qrscan is not on PATH.

Decode a QR image file with context

Create a scanner via qrscan.New(""), call scanner.Scan with a context, profile and budget, and keep detections whose Symbology is 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
}

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

Use qrscan.Unbounded instead of qrscan.ProfileBudget when you want reproducible scans independent of 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 need the full, unmodified engine JSON covering geometry, payloads and trace.

No code found 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 process per scan. Each Scan() call runs qrscan directly from an argument slice without invoking a shell, so paths containing spaces, quotes or leading dashes are never interpreted. This suits HTTP request handlers and batch jobs rather than tight loops over thousands of frames.

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

Untrusted payloads and licence. Treat decoded text as untrusted data and never open URLs automatically. Project-authored adapter source is MIT-licensed; see the Go adapter README and Go module GitHub repository.

Go QR Code Scanner documentation and licence

Official package guides, ScanReport specification and licensing references.

Go QR Code Scanner SDK questions

cgo, qrscan prerequisite, contexts, budgets, errors, 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 unchanged.

No. It requires Go 1.24 or newer, depends solely on the standard library and compiles cleanly with CGO_ENABLED=0. You only need the native qrscan binary installed on your host or baked into your container image.

An earlier trial running the engine inside Go via wazero yielded identical reports but ran roughly twenty times slower on photo-sized images. Driving native qrscan keeps native speed with zero cgo overhead.

Scan() accepts a file path (PNG, JPEG, WebP or GIF), so write in-memory uploads to a temporary file first. Because each scan launches a qrscan subprocess, it suits request handlers and batch jobs; for high-throughput in-process loops, use the Rust, Node.js, Python or .NET bindings.

When no code is present, report.Found() is false and err is nil. If report.Complete is false, the budget cut scanning short so an empty result is not final; retry with qrscan.Unbounded. Hard failures return ErrBinaryNotFound, *UnsupportedVersionError, *ScanError (with EngineCode) or ctx.Err().

Yes. The adapter executes qrscan from an explicit argument slice without invoking a shell, so spaces, quotes, leading dashes and shell metacharacters in file paths are never interpreted.

No. The adapter writes nothing, makes zero network calls and never fetches decoded URLs. Decoding executes entirely locally on your host or container with no QR Code AI account or API key.

Yes. Current releases of the Go adapter and qrscan engine ship under the MIT licence for commercial and proprietary services provided copyright and licence notices are preserved (see LICENSING.md). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.