qr

package
v0.1.65 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 2 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 qr is a small QR Code encoder (ISO/IEC 18004, Model 2): byte mode, versions 1-40, error correction levels L/M/Q/H. It exists so the CLI can print a QR code to a terminal without a dependency.

Index

Constants

This section is empty.

Variables

View Source
var ErrTooLong = errors.New("qr: data too long for a QR code")

ErrTooLong means the data does not fit in a version 40 symbol at the chosen level.

Functions

This section is empty.

Types

type Code

type Code struct {
	Size int // modules per side, 4*version+17
	// contains filtered or unexported fields
}

Code is an encoded symbol, without the quiet zone.

func Encode

func Encode(data []byte, level Level) (*Code, error)

Encode encodes data in byte mode in the smallest version that fits at level.

func (*Code) Black

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

Black reports whether the module at column x, row y is dark. Outside the symbol it is false.

func (*Code) Terminal

func (c *Code) Terminal(invert bool) string

Terminal draws the code with Unicode half blocks, two modules per text row, inside the 4-module quiet zone (ISO/IEC 18004 "Quiet zone"). Every row ends with a newline.

By default the light modules are the blocks, which scans on a dark terminal (light text on a dark background). With invert the dark modules are the blocks, for a light terminal.

type Level

type Level int

Level is the error correction level.

const (
	L Level = iota // recovers about 7% of the codewords
	M              // about 15%
	Q              // about 25%
	H              // about 30%
)

The order matches the rows of the tables.

Jump to

Keyboard shortcuts

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