qrcode

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package qrcode implements a deterministic, self-contained pure-Go ISO/IEC 18004 QR Code Model 2 encoder (versions 1–10, byte mode, error correction levels L/M/Q/H). It has zero external dependencies and compiles across desktop, mobile, and web targets.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyInput = errors.New("qrcode: input must not be empty")

ErrEmptyInput is returned when Encode receives an empty payload.

View Source
var ErrPayloadTooLarge = errors.New("qrcode: input exceeds maximum capacity")

ErrPayloadTooLarge is returned when the input exceeds version 10 capacity for the chosen level.

Functions

This section is empty.

Types

type Code

type Code struct {
	// Version is the ISO/IEC 18004 symbol version (1..10).
	Version int
	// Level is the error correction level used to encode the symbol.
	Level Level
	// Mask is the chosen data mask pattern (0..7).
	Mask int
	// Size is the module width and height (4*Version + 17).
	Size int
	// contains filtered or unexported fields
}

Code holds a finished QR Code symbol matrix.

func Encode

func Encode(text string, level Level) (*Code, error)

Encode encodes text as a deterministic ISO/IEC 18004 QR Code Model 2 symbol in byte mode at the smallest version (1..10) that fits text at error correction level.

func (*Code) Black

func (c *Code) Black(x, y int) bool

Black reports whether the module at column x, row y is dark. Coordinates outside [0, Size) return false (light quiet zone).

func (*Code) Matrix

func (c *Code) Matrix() [][]bool

Matrix returns a defensive Size×Size copy of the symbol's module grid (indexed [y][x]).

func (*Code) QuietZone

func (c *Code) QuietZone() int

QuietZone returns the standard 4-module light border width recommended by ISO/IEC 18004.

type Level

type Level int

Level selects the ISO/IEC 18004 error correction level.

const (
	// Low recovers up to ~7% codeword errors.
	Low Level = iota
	// Medium recovers up to ~15% codeword errors.
	Medium
	// Quartile recovers up to ~25% codeword errors.
	Quartile
	// High recovers up to ~30% codeword errors.
	High
)

func (Level) String

func (l Level) String() string

String returns the standard single-letter error correction code ("L", "M", "Q", or "H").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL