qrcode

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package qrcode is a thin platform seam over a QR-encoding library, mirroring the render package: it renders a QR code entirely server-side and returns it as a self-contained "data:image/png;base64,..." URI, so callers (Templ components) embed it directly in an <img src> with no client-side QR JS and no extra HTTP round trip to fetch the image.

The library used is github.com/yeqown/go-qrcode/v2 — an earlier candidate, skip2/go-qrcode, was rejected because that module is unmaintained (last release predates Go modules' current tooling expectations, no open-source activity in years); yeqown/go-qrcode is actively maintained and was chosen instead.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidModuleSize = errors.New("qrcode: moduleSize must be between 1 and 255")

ErrInvalidModuleSize is returned by PNGDataURI when moduleSize falls outside the range standard.WithQRWidth's uint8 parameter can represent (1-255). Validating here, before the int→uint8 conversion, turns an out-of-range value into an explicit error instead of a silently wrapped (e.g. 256 → 0) or negative-to-huge-unsigned pixel size.

Functions

func PNGDataURI

func PNGDataURI(content string, moduleSize int) (string, error)

PNGDataURI renders content (typically an absolute deep-link URL) as a QR code and returns it as a "data:image/png;base64,..." URI. moduleSize scales the PNG's pixel dimensions (pixels per QR module — see standard.WithQRWidth) and must be in [1, 255]; a caller with no specific sizing need can pass a small constant like 8, which comfortably reads at kiosk-card size.

Rendering is entirely in-memory (a bytes.Buffer, never a temp file), so this is safe to call on every kiosk page render with no filesystem access or cleanup concern.

Types

This section is empty.

Jump to

Keyboard shortcuts

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